-
Notifications
You must be signed in to change notification settings - Fork 10
refactor(deployment): implement functional options pattern for ModifyPolicyAssignment + include notScopes #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(deployment): implement functional options pattern for ModifyPolicyAssignment + include notScopes #231
Conversation
…olicyAssignment - Removed modifyPolicyAssignmentOptions struct - Implemented closure-based functional options that directly modify the policy assignment - Created option functions: WithParameters, WithEnforcementMode, WithNonComplianceMessages, WithIdentity, WithResourceSelectors, WithOverrides - Updated all callers to use the new functional options API - Added test to demonstrate flexibility of partial options - Name parameter remains required as specified - All tests passing Co-authored-by: matt-FFFFFF <16320656+matt-FFFFFF@users.noreply.github.com>
|
@copilot Excellent - now please add a functional option for NotScopes. (*assignment.Properties.NotScopes). This is of type Each string value should be a valid ARM resource ID. If supplied, the existing value of NotScopes is overwritten. |
…yAssignment - Added WithNotScopes option to set NotScopes ([]*string) on policy assignments - Validates each notScope is a valid ARM resource ID using arm.ParseResourceID - If supplied, the existing value of NotScopes is overwritten - Added comprehensive test coverage including valid/invalid resource IDs and overwrite behavior Co-authored-by: matt-FFFFFF <16320656+matt-FFFFFF@users.noreply.github.com>
- Added blank lines for better readability in functional option closures Co-authored-by: matt-FFFFFF <16320656+matt-FFFFFF@users.noreply.github.com>
Added |
|
@copilot FIlter out any nil values in the supplied []*string |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main Azure/alzlib#231 +/- ##
==========================================
+ Coverage 49.96% 50.40% +0.44%
==========================================
Files 49 49
Lines 3929 3966 +37
==========================================
+ Hits 1963 1999 +36
Misses 1704 1704
- Partials 262 263 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Modified WithNotScopes to filter out nil values from the supplied []*string slice - Only non-nil values are validated and assigned to NotScopes - Updated test to verify nil values are properly filtered out Co-authored-by: matt-FFFFFF <16320656+matt-FFFFFF@users.noreply.github.com>
Filtered out nil values in commit c38953e. The |
jaredfholgate
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question about non-compliance messages. This is regards the templating, etc.
Refactor ModifyPolicyAssignment to use functional options pattern ✅
Implementation Complete:
Summary:
Successfully refactored
ModifyPolicyAssignmentto use a closure-based functional options pattern for improved extensibility and cleaner API.Key Changes:
modifyPolicyAssignmentOptionsstruct (as requested)WithParameters(map[string]*armpolicy.ParameterValuesValue)WithEnforcementMode(*armpolicy.EnforcementMode)WithNonComplianceMessages([]*armpolicy.NonComplianceMessage)WithIdentity(*armpolicy.Identity)WithResourceSelectors([]*armpolicy.ResourceSelector)WithOverrides([]*armpolicy.Override)WithNotScopes([]*string)- validates ARM resource IDs, filters nil values, overwrites existing valueModifyPolicyAssignment(name string, opts ...ModifyPolicyAssignmentOption) errorhierarchy.goand test filesExample Usage:
Testing:
TestModifyPolicyAssignment_WithPartialOptionsto verify flexibilityTestModifyPolicyAssignment_WithNotScopeswith validation, overwrite, and nil filtering testsTestModifyPolicyAssignmentupdated to use new APIBenefits:
nilfor unused parametersOriginal prompt
func (mg *HierarchyManagementGroup) ModifyPolicyAssignment()Azure-Landing-Zones#1451✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.