Copilot commented on code in PR #289:
URL: 
https://github.com/apache/cloudstack-terraform-provider/pull/289#discussion_r3091511539


##########
cloudstack/resource_cloudstack_network.go:
##########
@@ -190,23 +191,25 @@ func resourceCloudStackNetworkCreate(d 
*schema.ResourceData, meta interface{}) e
                return err
        }
 
-       m, err := parseCIDR(d, no.Specifyipranges)
-       if err != nil {
-               return err
-       }
+       if _, ok := d.GetOk("cidr"); ok {

Review Comment:
   With `cidr` now optional, users can set `gateway`/`startip`/`endip` without 
setting `cidr`, but this branch will skip `parseCIDR` and those user-supplied 
values will be silently ignored (and `netmask` can’t be derived). Consider 
validating that `cidr` must be set whenever any of `gateway`, `startip`, or 
`endip` is configured (return a clear error), or otherwise handle those fields 
explicitly when `cidr` is absent.
   ```suggestion
        _, cidrConfigured := d.GetOk("cidr")
        if !cidrConfigured {
                if _, ok := d.GetOk("gateway"); ok {
                        return fmt.Errorf("cidr must be specified when gateway 
is configured")
                }
                if _, ok := d.GetOk("startip"); ok {
                        return fmt.Errorf("cidr must be specified when startip 
is configured")
                }
                if _, ok := d.GetOk("endip"); ok {
                        return fmt.Errorf("cidr must be specified when endip is 
configured")
                }
        }
   
        if cidrConfigured {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to