feat(projects): support contributor registry for default project role rules#6034
Conversation
… rules Add a `RoleRulesContributorRegistry` to the project reconciler that allows downstream distributions (e.g. Kargo EE) to inject additional PolicyRules into the default project roles (kargo-admin, kargo-viewer, kargo-promoter) at startup time, without needing to modify the core reconciler. The registry uses the existing `pkg/component.PredicateBasedRegistry` pattern. To support "apply all matching" semantics (vs. the existing "find first" semantics), a `GetAll()` method is added to the `PredicateBasedRegistry` interface and `listBasedRegistry` implementation. Callers register a `RoleRulesContributorRegistration` before calling `SetupReconcilerWithManager`. The reconciler applies all matching contributors when creating default roles for a new project. Part of: akuityio/kargo-enterprise#460 Signed-off-by: Eron Wright <eron.wright@akuity.io>
✅ Deploy Preview for docs-kargo-io ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6034 +/- ##
==========================================
+ Coverage 57.03% 57.07% +0.03%
==========================================
Files 463 464 +1
Lines 39112 39135 +23
==========================================
+ Hits 22309 22335 +26
+ Misses 15474 15472 -2
+ Partials 1329 1328 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@EronWright can this replace |
|
Yes — confirmed effective, and I'd like to handle it in a follow-up PR to keep the blast radius small here. The follow-up would introduce two additional registries modeled on the same ProjectSetupContributorRegistration // called during reconciliation
ProjectCleanupContributorRegistration // called on deletion
One ordering note worth capturing: setup contributors run after the OSS base resources are created (OSS → EE), while cleanup contributors run before the OSS base resources are deleted (EE → OSS), so that EE resources referencing OSS ClusterRoles are removed first. That symmetry wasn't present in the original |
| ] | ||
| ) | ||
|
|
||
| var defaultRoleRulesContributorRegistry = component.MustNewPredicateBasedRegistry[ |
There was a problem hiding this comment.
If that's a new registry, why use list with predicates and function with lookup by name instead of map registry?
Am I missing something?
There was a problem hiding this comment.
The main thing is that there's numerous registered contributors for a given key, and you want all of the contributors.
Summary
GetAll()to thePredicateBasedRegistryinterface (andlistBasedRegistryimplementation) inpkg/component, enabling "apply all matching" semantics in addition to the existing "find first" semantics.RoleRulesContributorRegistrationregistry inpkg/controller/management/projectsthat allows callers to inject additionalPolicyRules into the default project roles (kargo-admin,kargo-viewer,kargo-promoter) at startup time.ensureDefaultUserRolesfunction applies all registered contributors when creating default roles for a new project.Companion EE PR: akuityio/kargo-enterprise#460
Test plan
GetAll()inpkg/component/list_based_registry_test.gopkg/controller/management/projects/projects_test.go