refactor(kubernetes): export k.CanIUse func#775
Open
swghosh wants to merge 2 commits intocontainers:mainfrom
Open
refactor(kubernetes): export k.CanIUse func#775swghosh wants to merge 2 commits intocontainers:mainfrom
swghosh wants to merge 2 commits intocontainers:mainfrom
Conversation
Signed-off-by: Swarup Ghosh <swghosh@redhat.com>
Author
46b2b7e to
09d2757
Compare
Signed-off-by: Swarup Ghosh <swghosh@redhat.com>
09d2757 to
e603ee1
Compare
matzew
reviewed
Feb 12, 2026
| func (c *Core) canIUse(ctx context.Context, gvr *schema.GroupVersionResource, namespace, verb string) bool { | ||
| // CanIUse checks if the current user has permission to perform a specific verb on a resource. | ||
| // It uses SelfSubjectAccessReview to determine if the operation is allowed. | ||
| func (c *Core) CanIUse(ctx context.Context, gvr *schema.GroupVersionResource, namespace, verb string) bool { |
Collaborator
There was a problem hiding this comment.
currently this file just exposes "crud" operations.
Not sure if for a public func we might want to move it else?
Before was private, which is different story
Author
There was a problem hiding this comment.
any suggestions for a new package / existing package to place this func instea?
Member
|
This has a slight overlap with #764 Not sure if we can extract this somewhere so that it can be reused by both, or if we can reuse what's added in #764 once we merge it (cc @nader-ziada) |
Author
/close |
Collaborator
@swghosh were you trying to close the PR? i don't think this command works in this repo |
Member
|
I added the closes ref to the other PR. This PR will be closed automatically when we merge the other one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Certain downstream implementations (eg.) would want to call
k.CanIUsein other packages outsidepkg/kubernetes. CanIUse performs generic SubjectAccessReview calls to check if current user is authorized with certain resources, this is useful beyond the immediate package.Also, added a fake Kube client that allows mocking the CanIUse func in other dependent packages.
xref: openshift#51 (comment)