forked from LaconicNetwork/kompose
normalize docker-compose service that has name with underscore
kubernetes or openshift does not allow underscores in the object names, while docker-compose does, in this commit the code has been added to convert underscores to hypens.
This commit is contained in:
@@ -391,3 +391,7 @@ func handleServiceType(ServiceType string) string {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user