cli/compose: use strings.Cut
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -427,11 +427,11 @@ func uint32Ptr(value uint32) *uint32 {
|
||||
// convertExtraHosts converts <host>:<ip> mappings to SwarmKit notation:
|
||||
// "IP-address hostname(s)". The original order of mappings is preserved.
|
||||
func convertExtraHosts(extraHosts composetypes.HostsList) []string {
|
||||
hosts := []string{}
|
||||
hosts := make([]string, 0, len(extraHosts))
|
||||
for _, hostIP := range extraHosts {
|
||||
if v := strings.SplitN(hostIP, ":", 2); len(v) == 2 {
|
||||
if hostName, ipAddr, ok := strings.Cut(hostIP, ":"); ok {
|
||||
// Convert to SwarmKit notation: IP-address hostname(s)
|
||||
hosts = append(hosts, fmt.Sprintf("%s %s", v[1], v[0]))
|
||||
hosts = append(hosts, ipAddr+" "+hostName)
|
||||
}
|
||||
}
|
||||
return hosts
|
||||
|
||||
Reference in New Issue
Block a user