diff --git a/cmd/completion.go b/cmd/completion.go index 8c68a3d4..83de4735 100644 --- a/cmd/completion.go +++ b/cmd/completion.go @@ -3,10 +3,11 @@ package cmd import ( "bytes" "fmt" - "github.com/Sirupsen/logrus" - "github.com/spf13/cobra" "io" "os" + + "github.com/Sirupsen/logrus" + "github.com/spf13/cobra" ) var completion = &cobra.Command{ diff --git a/pkg/app/app.go b/pkg/app/app.go index 9df4bd9f..caef4f11 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -33,12 +33,13 @@ import ( _ "github.com/openshift/origin/pkg/image/api/install" _ "github.com/openshift/origin/pkg/route/api/install" + "os" + "github.com/kubernetes-incubator/kompose/pkg/kobject" "github.com/kubernetes-incubator/kompose/pkg/loader" "github.com/kubernetes-incubator/kompose/pkg/transformer" "github.com/kubernetes-incubator/kompose/pkg/transformer/kubernetes" "github.com/kubernetes-incubator/kompose/pkg/transformer/openshift" - "os" ) const ( diff --git a/pkg/loader/compose/compose.go b/pkg/loader/compose/compose.go index 29a4ed67..07a4b4d1 100644 --- a/pkg/loader/compose/compose.go +++ b/pkg/loader/compose/compose.go @@ -391,3 +391,7 @@ func handleServiceType(ServiceType string) string { return "" } } + +func normalizeServiceNames(svcName string) string { + return strings.Replace(svcName, "_", "-", -1) +} diff --git a/pkg/loader/compose/compose_test.go b/pkg/loader/compose/compose_test.go index 068001d2..79d44413 100644 --- a/pkg/loader/compose/compose_test.go +++ b/pkg/loader/compose/compose_test.go @@ -263,3 +263,22 @@ func TestUnsupportedKeys(t *testing.T) { } } + +func TestNormalizeServiceNames(t *testing.T) { + testCases := []struct { + composeServiceName string + normalizedServiceName string + }{ + {"foo_bar", "foo-bar"}, + {"foo", "foo"}, + {"foo.bar", "foo.bar"}, + //{"", ""}, + } + + for _, testCase := range testCases { + returnValue := normalizeServiceNames(testCase.composeServiceName) + if returnValue != testCase.normalizedServiceName { + t.Logf("Expected %q, got %q", testCase.normalizedServiceName, returnValue) + } + } +}