MCPcopy Create free account
hub / github.com/docker/cli / convertExtraHostsToSwarmHosts

Function convertExtraHostsToSwarmHosts

cli/command/service/opts.go:533–542  ·  view source on GitHub ↗

convertExtraHostsToSwarmHosts converts an array of extra hosts in cli : into a swarmkit host format: IP_address canonical_hostname [aliases...] This assumes input value ( : ) has already been validated

(extraHosts []string)

Source from the content-addressed store, hash-verified

531//
532// This assumes input value (<host>:<ip>) has already been validated
533func convertExtraHostsToSwarmHosts(extraHosts []string) []string {
534 hosts := make([]string, 0, len(extraHosts))
535 for _, extraHost := range extraHosts {
536 host, ip, ok := strings.Cut(extraHost, ":")
537 if ok {
538 hosts = append(hosts, ip+" "+host)
539 }
540 }
541 return hosts
542}
543
544type serviceOptions struct {
545 detach bool

Callers 2

updateHostsFunction · 0.85
ToServiceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…