forked from LaconicNetwork/kompose
Merge pull request #429 from surajssd/change_service_names
normalize docker-compose service that has name with underscore
This commit is contained in:
commit
816b74811d
@ -3,10 +3,11 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var completion = &cobra.Command{
|
var completion = &cobra.Command{
|
||||||
|
|||||||
@ -33,12 +33,13 @@ import (
|
|||||||
_ "github.com/openshift/origin/pkg/image/api/install"
|
_ "github.com/openshift/origin/pkg/image/api/install"
|
||||||
_ "github.com/openshift/origin/pkg/route/api/install"
|
_ "github.com/openshift/origin/pkg/route/api/install"
|
||||||
|
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/kubernetes-incubator/kompose/pkg/kobject"
|
"github.com/kubernetes-incubator/kompose/pkg/kobject"
|
||||||
"github.com/kubernetes-incubator/kompose/pkg/loader"
|
"github.com/kubernetes-incubator/kompose/pkg/loader"
|
||||||
"github.com/kubernetes-incubator/kompose/pkg/transformer"
|
"github.com/kubernetes-incubator/kompose/pkg/transformer"
|
||||||
"github.com/kubernetes-incubator/kompose/pkg/transformer/kubernetes"
|
"github.com/kubernetes-incubator/kompose/pkg/transformer/kubernetes"
|
||||||
"github.com/kubernetes-incubator/kompose/pkg/transformer/openshift"
|
"github.com/kubernetes-incubator/kompose/pkg/transformer/openshift"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@ -391,3 +391,7 @@ func handleServiceType(ServiceType string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func normalizeServiceNames(svcName string) string {
|
||||||
|
return strings.Replace(svcName, "_", "-", -1)
|
||||||
|
}
|
||||||
|
|||||||
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user