Add unit test for komposeConvert

This commit is contained in:
Janet Kuo
2016-08-12 18:21:56 -07:00
parent 3fcfb71006
commit 14726f1a53
6 changed files with 259 additions and 36 deletions
+6 -4
View File
@@ -20,6 +20,8 @@ import (
"io/ioutil"
"strings"
"k8s.io/kubernetes/pkg/api"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/client/bundlefile"
"github.com/skippbox/kompose/pkg/kobject"
@@ -78,14 +80,14 @@ func loadEnvVarsfromBundle(service bundlefile.Service) ([]kobject.EnvVar, string
func loadPortsfromBundle(service bundlefile.Service) ([]kobject.Ports, string) {
ports := []kobject.Ports{}
for _, port := range service.Ports {
var p kobject.Protocol
var p api.Protocol
switch port.Protocol {
default:
p = kobject.ProtocolTCP
p = api.ProtocolTCP
case "TCP":
p = kobject.ProtocolTCP
p = api.ProtocolTCP
case "UDP":
p = kobject.ProtocolUDP
p = api.ProtocolUDP
}
ports = append(ports, kobject.Ports{
HostPort: int32(port.Port),
+3 -1
View File
@@ -22,6 +22,8 @@ import (
"strconv"
"strings"
"k8s.io/kubernetes/pkg/api"
"github.com/Sirupsen/logrus"
"github.com/docker/libcompose/config"
"github.com/docker/libcompose/docker"
@@ -50,7 +52,7 @@ func loadPortsFromCompose(composePorts []string) ([]kobject.Ports, string) {
ports := []kobject.Ports{}
character := ":"
for _, port := range composePorts {
p := kobject.ProtocolTCP
p := api.ProtocolTCP
if strings.Contains(port, character) {
hostPort := port[0:strings.Index(port, character)]
hostPort = strings.TrimSpace(hostPort)