1
0
mirror of https://github.com/rancher/types.git synced 2025-04-28 02:30:07 +00:00

Use default mapper for hostport conversion

This commit is contained in:
Alena Prokharchyk 2019-11-06 11:00:22 -08:00
parent e9d59cb739
commit 9644e7bb84

View File

@ -98,13 +98,11 @@ func (n ContainerPorts) ToInternal(data map[string]interface{}) error {
logrus.Warnf("Failed to encode port: %v", err)
return obj
}
if strings.EqualFold(convert.ToString(mapped["kind"]), "HostPort") {
if _, ok := mapped["sourcePort"]; ok {
mapped["hostPort"] = mapped["sourcePort"]
}
if !strings.EqualFold(convert.ToString(mapped["kind"]), "HostPort") {
// delete the source port so it doesn't get converted to the host port by default mapper
delete(mapped, "sourcePort")
}
// delete the source port so it doesn't get converted to the host port by default mapper
delete(mapped, "sourcePort")
}
ports = append(ports, l)
}