Skip to content

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

Open
agmimidi wants to merge 3 commits intoalcideio:masterfrom
agmimidi:support-subresources-define-namespace-and-name
Open

Gen command improvements: Support for subresources and for defining namespace and name of generated roles#102
agmimidi wants to merge 3 commits intoalcideio:masterfrom
agmimidi:support-subresources-define-namespace-and-name

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 requested a review from gadinaor-r7 April 25, 2024 15:46
@gadinaor gadinaor added the enhancement New feature or request label Apr 25, 2024
func generateRole(rules []rbacv1.PolicyRule, namespace string, roleName string) (string, error) {
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