don't use net.IPMask
net.IPMask doesn't have any advantages, as it would marshalled to mask: - 1 - 2 - 3 - 4 Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
9fdb9ca792
commit
c08cd82e68
@@ -150,7 +150,6 @@ func recursiveFlatten(obj interface{}) (hasContent bool) {
|
||||
for mapIter.Next() {
|
||||
if mapIter.Value().Kind() == reflect.String {
|
||||
if mapIter.Value().String() != "" {
|
||||
// fmt.Println("map")
|
||||
hasContent = true
|
||||
}
|
||||
} else {
|
||||
@@ -203,12 +202,6 @@ func recursiveFlatten(obj interface{}) (hasContent bool) {
|
||||
if len(val) != 0 && !val.IsUnspecified() {
|
||||
hasContent = true
|
||||
}
|
||||
case reflect.TypeOf(net.IPMask{}):
|
||||
val := valObj.Elem().Field(i).Interface().(net.IPMask)
|
||||
if len(val) != 0 {
|
||||
// fmt.Println("Mask")
|
||||
hasContent = true
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -346,3 +339,18 @@ func cleanList(list []string) (ret []string) {
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
/*
|
||||
Return the ipv4 address and mask in CIDR format. Aimed for the use in
|
||||
templates.
|
||||
*/
|
||||
func (netdev *NetDevs) IpCIDR() string {
|
||||
if netdev.Ipaddr.IsUnspecified() || netdev.Netmask.IsUnspecified() {
|
||||
return ""
|
||||
}
|
||||
ipCIDR := net.IPNet{
|
||||
IP: netdev.Ipaddr,
|
||||
Mask: net.IPMask(netdev.Netmask),
|
||||
}
|
||||
return ipCIDR.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user