Skip to content

Commit 082457c

Browse files
committed
udn, nad template: Move l2 validations closer to each other
Signed-off-by: Or Mergi <[email protected]>
1 parent 1466f21 commit 082457c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

go-controller/pkg/clustermanager/userdefinednetwork/template/net-attach-def-template.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,16 @@ func renderCNINetworkConfig(networkName, nadName string, spec SpecGetter) (map[s
138138
if err := validateIPAM(cfg.IPAM); err != nil {
139139
return nil, err
140140
}
141-
netConfSpec.Role = strings.ToLower(string(cfg.Role))
142-
netConfSpec.MTU = int(cfg.MTU)
143-
netConfSpec.AllowPersistentIPs = cfg.IPAM != nil && cfg.IPAM.Lifecycle == userdefinednetworkv1.IPAMLifecyclePersistent
144141
if ipamEnabled(cfg.IPAM) && len(cfg.Subnets) == 0 {
145142
return nil, fmt.Errorf("subnets is required with ipam.mode is Enabled or unset")
146143
}
147144
if !ipamEnabled(cfg.IPAM) && len(cfg.Subnets) > 0 {
148145
return nil, fmt.Errorf("subnets must be unset when ipam.mode is Disabled")
149146
}
147+
148+
netConfSpec.Role = strings.ToLower(string(cfg.Role))
149+
netConfSpec.MTU = int(cfg.MTU)
150+
netConfSpec.AllowPersistentIPs = cfg.IPAM != nil && cfg.IPAM.Lifecycle == userdefinednetworkv1.IPAMLifecyclePersistent
150151
netConfSpec.Subnets = cidrString(cfg.Subnets)
151152
netConfSpec.JoinSubnet = cidrString(renderJoinSubnets(cfg.Role, cfg.JoinSubnets))
152153
}

0 commit comments

Comments
 (0)