Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen command improvements: Support for subresources and for defining namespace and name of generated roles #102

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

agmimidi
Copy link

@agmimidi agmimidi commented Apr 2, 2024

This MR provides the following additional functionality.

  1. Enables the use of an additional flag for the gen command named --useSubresouces. When this is defined, then the gen command also includes Kubernetes subresources (e.g. pods/exec) when generating Roles or Cluster roles. To avoid breaking existing functionality, default behaviour is to have this flag disabled.
  2. Enables the use of two additional flags named --roleName and --namespace to define the name of the generated (cluster)role and of the target namespace. If none is defines, default behaviour is maintained (name=myRole, namespace=myNamespace)

Example use of new flags

Only define namespace and name of Role
rbac-tool gen --roleName me --namespace mine --deny-resources=secrets.,services. --allowed-verbs=get,list --generated-type=Role

Include also subresources
rbac-tool gen --roleName me --namespace mine --deny-resources=secrets.,services. --allowed-verbs=get,list --generated-type=Role --useSubresources

Tested in an M1 Chip
out_no_subresources.txt
out_subresources_no_names.txt
out_subresources.txt

@gadinaor gadinaor added the enhancement New feature or request label Apr 25, 2024
var obj runtime.Object

if generateKind == "ClusterRole" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR removes support for generating cluster roles - is this intended? I'd rather add have this PR extend the existing behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants