You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support deprecated 'ports' field for backward compatibility
The 'ports' field in the legacy 'rule' block was documented as being
kept 'for backward compatibility only', but the provider was rejecting
it during rule creation/verification. This commit implements full
support for the deprecated field to match the documentation.
Changes:
1. Rule Expansion:
- When a rule uses 'ports' with multiple values (e.g., ['80', '443']),
the provider now creates separate CloudStack ACL rules for each port
- Each expanded rule gets a unique, sequential rule number
- Port ranges (e.g., '8000-8100') are supported and treated as single
entries
2. Auto-Numbering Enhancement:
- Updated assignRuleNumbers() to detect 'ports' usage and reserve
enough sequential numbers for all expanded rules
- Ensures subsequent rule blocks don't collide with expanded rules
- Example: A rule with ports=['80','443'] reserves numbers N and N+1
3. Validation:
- Added validation to prevent explicit 'rule_number' when 'ports'
contains multiple values, since the provider must manage numbering
for expansion
- Moved validation to occur before auto-numbering so it can
distinguish between user-provided and auto-assigned numbers
- Clear error message guides users to either:
* Use a single port in 'ports'
* Omit 'rule_number' (let it auto-assign)
* Migrate to the new 'port' field with explicit rule_number
4. Comprehensive Testing:
- TestAccCloudStackNetworkACLRule_deprecated_ports: Basic functionality
test verifying multiple ports and port ranges are expanded correctly
- TestAccCloudStackNetworkACLRule_deprecated_ports_managed: Verifies
that managed=true behavior works correctly with expanded rules,
including deletion of out-of-band rules
- TestAccCloudStackNetworkACLRule_deprecated_ports_not_managed: Verifies
that managed=false preserves out-of-band rules when using deprecated
ports field
All 15 NetworkACLRule acceptance tests pass, ensuring existing
configurations using the deprecated 'ports' field continue to work
as documented.
log.Printf("[ERROR] Attempt to create rule with deprecated ports field")
643
-
returnfmt.Errorf("The 'ports' field is no longer supported for creating new rules. Please use the 'port' field with separate rules for each port/range.")
644
-
}
645
-
655
+
// Check if deprecated ports field is used (for backward compatibility)
0 commit comments