engine: resources: net: Allow addr without gateway
In some scenarios it is desirable to set the addrs and gateway independently, i.e. if a default gateway is already set on the machine. This patch removes the requirement to set them together.
This commit is contained in:
@@ -119,9 +119,6 @@ func (obj *NetRes) Validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate network address input
|
// validate network address input
|
||||||
if (obj.Addrs == nil) != (obj.Gateway == "") {
|
|
||||||
return fmt.Errorf("addrs and gateway must both be set or both be empty")
|
|
||||||
}
|
|
||||||
if obj.Addrs != nil {
|
if obj.Addrs != nil {
|
||||||
for _, addr := range obj.Addrs {
|
for _, addr := range obj.Addrs {
|
||||||
if _, _, err := net.ParseCIDR(addr); err != nil {
|
if _, _, err := net.ParseCIDR(addr); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user