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

Function convertExtraHosts

cli/compose/convert/service.go:422–431  ·  view source on GitHub ↗

convertExtraHosts converts : mappings to SwarmKit notation: "IP-address hostname(s)". The original order of mappings is preserved.

(extraHosts composetypes.HostsList)

Source from the content-addressed store, hash-verified

420// convertExtraHosts converts <host>:<ip> mappings to SwarmKit notation:
421// "IP-address hostname(s)". The original order of mappings is preserved.
422func convertExtraHosts(extraHosts composetypes.HostsList) []string {
423 hosts := make([]string, 0, len(extraHosts))
424 for _, hostIP := range extraHosts {
425 if hostName, ipAddr, ok := strings.Cut(hostIP, ":"); ok {
426 // Convert to SwarmKit notation: IP-address hostname(s)
427 hosts = append(hosts, ipAddr+" "+hostName)
428 }
429 }
430 return hosts
431}
432
433func convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container.HealthConfig, error) {
434 if healthcheck == nil {

Callers 2

TestConvertExtraHostsFunction · 0.85
ServiceFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestConvertExtraHostsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…