Skip to content

Commit

Permalink
changed container normalization to use its new own normalization func…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
rcmorano committed Aug 11, 2018
1 parent 2ed339c commit 1d1e13f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/loader/compose/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func handleServiceType(ServiceType string) (string, error) {
}
}

func normalizeContainerNames(svcName string) string {
return strings.ToLower(svcName)
}

func normalizeServiceNames(svcName string) string {
re := regexp.MustCompile("[._]")
return strings.ToLower(re.ReplaceAllString(svcName, "-"))
Expand Down
2 changes: 1 addition & 1 deletion pkg/loader/compose/v1v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func libComposeToKomposeMapping(composeObject *project.Project) (kobject.Kompose
serviceConfig := kobject.ServiceConfig{}
serviceConfig.Image = composeServiceConfig.Image
serviceConfig.Build = composeServiceConfig.Build.Context
newName := normalizeServiceNames(composeServiceConfig.ContainerName)
newName := normalizeContainerNames(composeServiceConfig.ContainerName)
serviceConfig.ContainerName = newName
if newName != composeServiceConfig.ContainerName {
log.Infof("Container name in service %q has been changed from %q to %q", name, composeServiceConfig.ContainerName, newName)
Expand Down
2 changes: 1 addition & 1 deletion pkg/loader/compose/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
serviceConfig.Stdin = composeServiceConfig.StdinOpen
serviceConfig.Tty = composeServiceConfig.Tty
serviceConfig.TmpFs = composeServiceConfig.Tmpfs
serviceConfig.ContainerName = normalizeServiceNames(composeServiceConfig.ContainerName)
serviceConfig.ContainerName = normalizeContainerNames(composeServiceConfig.ContainerName)
serviceConfig.Command = composeServiceConfig.Entrypoint
serviceConfig.Args = composeServiceConfig.Command
serviceConfig.Labels = composeServiceConfig.Labels
Expand Down

0 comments on commit 1d1e13f

Please sign in to comment.