You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by "sudo87 (via GitHub)" <gi...@apache.org> on 2025/08/25 11:36:51 UTC

[PR] Support desc and ruleId in create_network_acl_rule [cloudstack-terraform-provider]

sudo87 opened a new pull request, #203:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203

   This pr fixes:  https://github.com/apache/cloudstack-terraform-provider/issues/106
   


-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support desc and ruleId in create_network_acl_rule [cloudstack-terraform-provider]

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 closed pull request #203: Support desc and ruleId in create_network_acl_rule
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203


-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support desc and rule_number in create_network_acl_rule [cloudstack-terraform-provider]

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #203:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203#issuecomment-3226983122

   The below configuration is failing. As of now, it looks like rule_number doesn't work when ports are specified. Because before the implementation, each port was getting assigned different rule number. This will require updates in terraform docs accordingly.
   ```hcl
   resource "cloudstack_network_acl_rule" "foo" {
     acl_id = cloudstack_network_acl.foo.id
   
     rule {
     	rule_number = 20
     	action = "allow"
       cidr_list = ["172.18.100.0/20"]
       ports = ["80", "443"]
       protocol = "tcp"
       traffic_type = "ingress"
   	description = "Allow tcp traffic"
     }
   }
   ```


-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support desc and ruleId in create_network_acl_rule [cloudstack-terraform-provider]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland closed pull request #203: Support desc and ruleId in create_network_acl_rule
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203


-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support desc and rule_number in create_network_acl_rule [cloudstack-terraform-provider]

Posted by "sudo87 (via GitHub)" <gi...@apache.org>.
sudo87 commented on PR #203:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203#issuecomment-3227039463

   Thanks @vishesh92 for review comments and suggestions. PR is updated with the suggested changes. 


-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support desc and ruleId in create_network_acl_rule [cloudstack-terraform-provider]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland closed pull request #203: Support desc and ruleId in create_network_acl_rule
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203


-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support desc and rule_number in create_network_acl_rule [cloudstack-terraform-provider]

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #203:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203#discussion_r2302993332


##########
website/docs/r/network_acl_rule.html.markdown:
##########
@@ -48,6 +48,8 @@ The following arguments are supported:
 
 The `rule` block supports:
 
+* `rule_number` - (Optional) The number of the ACL item, its ordering.

Review Comment:
   IMO, this description is confusing.



-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support desc and ruleId in create_network_acl_rule [cloudstack-terraform-provider]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #203:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203#discussion_r2297908910


##########
cloudstack/resource_cloudstack_network_acl_rule.go:
##########
@@ -623,6 +644,15 @@ func verifyNetworkACLParams(d *schema.ResourceData) error {
 }
 
 func verifyNetworkACLRuleParams(d *schema.ResourceData, rule map[string]interface{}) error {
+	if ruleId, ok := rule["rule_id"]; ok && ruleId != nil {
+		if rId, ok := ruleId.(int); ok && rId > 0 {
+			if rId < 1 || rId > 65535 {
+				return fmt.Errorf(
+					"%q must be between %d and %d inclusive, got: %d", "rule_id", 1, 65535, rId)
+			}
+		}
+	}

Review Comment:
   The validation logic is redundant and incorrect. The condition `rId > 0` on line 648 already ensures the value is greater than 0, making the `rId < 1` check on line 649 unreachable. Remove the `rId < 1` condition.



-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support desc and rule_number in create_network_acl_rule [cloudstack-terraform-provider]

Posted by "kiranchavala (via GitHub)" <gi...@apache.org>.
kiranchavala merged PR #203:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203


-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support desc and rule_number in create_network_acl_rule [cloudstack-terraform-provider]

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #203:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203#discussion_r2302985741


##########
cloudstack/resource_cloudstack_network_acl_rule.go:
##########
@@ -623,6 +644,16 @@ func verifyNetworkACLParams(d *schema.ResourceData) error {
 }
 
 func verifyNetworkACLRuleParams(d *schema.ResourceData, rule map[string]interface{}) error {
+	if ruleNum, ok := rule["rule_number"]; ok && ruleNum != nil {
+		if rId, ok := ruleNum.(int); ok && rId != 0 {
+			// Validate only if rule_number is explicitly set (non-zero)
+			if rId < 1 || rId > 65535 {
+				return fmt.Errorf(
+					"%q must be between %d and %d inclusive, got: %d", "rule_number", 1, 65535, rId)
+			}
+		}

Review Comment:
   ```suggestion
   		if number, ok := ruleNum.(int); ok && number != 0 {
   			// Validate only if rule_number is explicitly set (non-zero)
   			if number < 1 || number > 65535 {
   				return fmt.Errorf(
   					"%q must be between %d and %d inclusive, got: %d", "rule_number", 1, 65535, number)
   			}
   		}
   ```



-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support desc and rule_number in create_network_acl_rule [cloudstack-terraform-provider]

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #203:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/203#discussion_r2302984116


##########
cloudstack/resource_cloudstack_network_acl_rule.go:
##########
@@ -198,6 +209,11 @@ func createNetworkACLRule(d *schema.ResourceData, meta interface{}, rule map[str
 	// Create a new parameter struct
 	p := cs.NetworkACL.NewCreateNetworkACLParams(rule["protocol"].(string))
 
+	// If a rule ID is specified, set it
+	if ruleId, ok := rule["rule_number"].(int); ok && ruleId > 0 {
+		p.SetNumber(ruleId)
+	}

Review Comment:
   ```suggestion
   	if ruleNum, ok := rule["rule_number"].(int); ok && ruleNum > 0 {
   		p.SetNumber(ruleNum)
   	}
   ```



-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org