Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new role primitive to the operator-component-framework to manage Kubernetes rbac.authorization.k8s.io/v1 Role resources using the same builder/mutation/flavor patterns as existing primitives, plus supporting docs and an example.
Changes:
- Introduces
pkg/primitives/role(resource, builder, mutator, flavors) and associated unit tests. - Adds a shared
PolicyRulesEditorunderpkg/mutation/editorsfor typed.rulesmanipulation. - Adds an end-to-end example (
examples/role-primitive) and documentation (docs/primitives/role.md) for the new primitive.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/primitives/role/resource.go | Role static resource wrapper over internal/generic.StaticResource |
| pkg/primitives/role/builder.go | Fluent builder for configuring Role resource (mutations/flavors/applicator/extractors) |
| pkg/primitives/role/mutator.go | Role mutator with metadata + rules editors and planned application |
| pkg/primitives/role/flavors.go | Role field-application flavors (preserve labels/annotations) |
| pkg/primitives/role/builder_test.go | Builder validation and registration tests |
| pkg/primitives/role/mutator_test.go | Mutator editor behavior + ordering tests |
| pkg/primitives/role/flavors_test.go | Flavor unit + integration tests via Resource.Mutate |
| pkg/mutation/editors/policyrules.go | New shared editor for []rbacv1.PolicyRule |
| pkg/mutation/editors/policyrules_test.go | Unit tests for the new PolicyRulesEditor |
| examples/role-primitive/main.go | Runnable example using a fake client to demonstrate reconciliation cycles |
| examples/role-primitive/app/controller.go | Minimal controller wiring a component with the role resource |
| examples/role-primitive/features/mutations.go | Example feature-gated mutations composing RBAC rules |
| examples/role-primitive/resources/role.go | Factory assembling the role resource with mutations + extractor |
| examples/role-primitive/README.md | Documentation for running/understanding the example |
| docs/primitives/role.md | New primitive documentation covering API, ordering, flavors, usage patterns |
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored:
|
Claude Review Cycle 2 CompleteAddressed: Intentionally ignored:
<!-- claude-review-cycle --> |
|
approved |
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored:
<!-- claude-review-cycle --> |
Claude Review Cycle 1 CompleteAddressed: Intentionally ignored:
<!-- claude-review-cycle --> |
Introduces a typed editor for mutating the .rules field of RBAC resources. Provides SetRules (atomic replace), AddRule (append), and Raw (escape hatch). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements the Role primitive as a Static resource with builder, mutator, resource wrapper, and flavors following the ConfigMap reference pattern. The mutator supports EditObjectMetadata and EditRules with plan-and-apply. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Documents the Role primitive API including building, mutations, editors, flavors, internal ordering, and usage guidance. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Demonstrates feature-gated RBAC rule composition using the role primitive, with base rules, version labelling, and conditional secret/metrics access. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address Copilot review comment requesting integration tests for Identity/Object/Mutate/ExtractData, mirroring the existing ConfigMap resource_test.go coverage. Tests cover baseline mutation, feature-gated mutations, feature ordering, custom field applicators (success and error), deep-copy safety, and data extractor error propagation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add nil panic guard to NewPolicyRulesEditor for consistency with NewConfigMapDataEditor - Add unit test for nil panic behavior - Fix docs referencing non-existent EnableSecretAccess field (use EnableTracing to match example code) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Initialize the first feature plan inline instead of calling beginFeature(), matching the fix applied to deployment and configmap mutators. This prevents an empty feature from being created when the generic helper in mutator_helper.go calls fm.beginFeature(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Align with architectural change in main where FeatureMutator interface now requires exported BeginFeature() instead of unexported beginFeature(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e921353 to
e7a6ce9
Compare
# Conflicts: # docs/primitives.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude Review Cycle 1 CompleteAddressed: Intentionally ignored:
<!-- claude-review-cycle --> |
Align role primitive's NewMutator with configmap and deployment primitives — require BeginFeature before registering mutations. Add constructor/feature-plan invariant tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements the
roleKubernetes resource primitive following the pattern established by the existingConfigMapandDeploymentprimitives.Summary
roleprimitive package underpkg/primitives/role/Checklist