fix(api-server)!: when normalizing roles, make wildcard verb for stages include promote #2877
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #2864
When creating/updating "Kargo Roles," which are an abstraction over a ServiceAccount/Role/RoleBinding trio, policy rules are normalized when read from or written to the underlying Role. Among other things, this normalization includes expansion of the verb
*
tocreate, delete, deletecollection, get, list, patch, update, watch
.Stages have an additional, custom
promote
verb that is unaccounted for.The result is that when, the
*
verb is used in defining policy rules involving non-Stage resource types, the*
correctly expands to all the verbs supported by those resource types, but when using the*
verb in defining policy rules involving the Stage resource type, the expanded verbs lack the important custompromote
verb.This PR special cases expansion of the
*
verb when the resource type in the policy rule isstages
, but only does so for verbs that are being added/removed. When normalizing existing rules, whether simply for retrieval/display or in preparation to be modified, expansion of*
does not include the custompromote
verb because Kubernetes itself does not interpret a*
verb in a Role's policy rules as including any custom verbs.This is breaking only insofar as it expands the meaning of
*
in relation to creating/updating "Kargo Roles" going forward. This has no effect on anything existing.