Skip to content

contrib/kcp: generate bootstrap APIBinding permission claims in a loop - #654

Open
NopeCharon wants to merge 1 commit into
kbind-dev:mainfrom
NopeCharon:simplify-bootstrap-permission-claims
Open

NopeCharon wants to merge 1 commit into
kbind-dev:mainfrom
NopeCharon:simplify-bootstrap-permission-claims

Conversation

@NopeCharon

Copy link
Copy Markdown

Summary

bindAPIExport in contrib/kcp/deploy/bootstrap.go spelled out each of the 13 accepted permission claims of the kube-bind.io APIBinding as a fully nested AcceptablePermissionClaim literal. The entries only differed in group/resource: all of them use verbs *, MatchAll: true and state Accepted.

This PR follows the suggestion from the review discussion linked in the issue and keeps only the claimed GroupResources in an acceptedPermissionClaims list, building the claims from it in a loop (~190 fewer lines).

The generated APIBinding spec does not change. I checked this with a throwaway test against the kcp fake clientset: the claims produced by the new code are reflect.DeepEqual to the old literal, with the same 13 entries in the same order. go vet and golangci-lint (repo config) pass for contrib/kcp/deploy.

What Type of PR Is This?

/kind cleanup

Related Issue(s)

Fixes #286

Release Notes

NONE

bindAPIExport spelled out every accepted permission claim of the
kube-bind.io APIBinding as a fully nested AcceptablePermissionClaim
literal. All thirteen entries were identical apart from the group and
resource: every one grants all verbs ("*"), matches all objects and is
in the Accepted state. That made the list ~200 lines long and hard to
review or extend.

Keep only the claimed GroupResources in a package-level
acceptedPermissionClaims list and build the AcceptablePermissionClaims
from it in a loop. The resulting APIBinding spec is unchanged: the same
claims are produced in the same order with the same verbs, selector and
state.

Fixes kbind-dev#286

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify permission generation

1 participant