Merge pull request #28299 from vdemeester/compose-swarm-extra_hosts

Add support for extra_hosts in compose to swarm
This commit is contained in:
Brian Goff 2016-11-11 10:54:53 -05:00 committed by GitHub
commit e0280c568a
1 changed files with 9 additions and 0 deletions

View File

@ -498,6 +498,7 @@ func convertService(
Command: service.Entrypoint,
Args: service.Command,
Hostname: service.Hostname,
Hosts: convertExtraHosts(service.ExtraHosts),
Env: convertEnvironment(service.Environment),
Labels: getStackLabels(namespace.name, service.Labels),
Dir: service.WorkingDir,
@ -521,6 +522,14 @@ func convertService(
return serviceSpec, nil
}
func convertExtraHosts(extraHosts map[string]string) []string {
hosts := []string{}
for host, ip := range extraHosts {
hosts = append(hosts, fmt.Sprintf("%s %s", host, ip))
}
return hosts
}
func convertRestartPolicy(restart string, source *composetypes.RestartPolicy) (*swarm.RestartPolicy, error) {
// TODO: log if restart is being ignored
if source == nil {