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

Add metadata flags for name, namespace and annotations #92

Closed
paulbarfuss opened this issue Dec 8, 2023 · 5 comments · Fixed by #105
Closed

Add metadata flags for name, namespace and annotations #92

paulbarfuss opened this issue Dec 8, 2023 · 5 comments · Fixed by #105
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@paulbarfuss
Copy link

What would you like to be added:

Add flags to customize:

  • Metadata.Name
  • Metadata.Namespace
  • Metadata.Annotations

Why is this needed:

For the rbac-tool gen and rbac-tool show commands it would be useful for automation to be able to customize the object metadata during role generation.

For example:

# Generate a ClusterRole with all the available permissions for core and apps api groups
rbac-tool show \
  --for-groups=,apps \
  --scope namespace \
  --name foo \
  --namespace bar \
  --annotations argocd.argoproj.io/sync-wave=2,rbac.authorization.kubernetes.io/autoupdate=true

With these flags it would be possible to generate fully functional roles without having to make modifications to the YAML after running the tool.

@gadinaor
Copy link
Contributor

gadinaor commented Jan 1, 2024

@paulbarfuss - HNY and thanks for the above - few questions/comments:

  • gen command was intended to be used in automation pipeline and the proposed changes looks fine. I would just keep the existing values (for name and namespace) as the default for the cli options you've added.

  • show originally intended to be something that help a user to better understand the overall cluster permissions and the underlying aspects (verbs, kind, resources, ...) of those permissions. How do you see show command used in a automations workflow?

@paulbarfuss
Copy link
Author

HNY to you as well @gadinaor

Thank you for having a look! I am going to remove the merge logic on the show command as that should be a separate GH issue and may circle back to that at a later date.

The short answer is that I was looking for a way to manage RBAC like rbac-tool gen that includes the ability to fine tune access to subresources.

I will update the name/namespace to match the existing values as well on the open PR as there is some good value in those changes, as long as they don't modify existing behavior with the default values.

@diesello
Copy link

Hi @paulbarfuss

Dud you have a chance to look into it and update the code?

@paulbarfuss
Copy link
Author

Hi @gadinaor

I have updated the PR to better maintain the original intent and functionality of the gen and show commands.

The original thought around using show to generate RBAC is to leverage the generateRulesWithSubResources function in case a user wanted to define sub-resources. I dropped that added function from the new PR and only included the metadata flags as this would be very useful without introducing any breaking changes, or changing the current default values.

@gadinaor-r7
Copy link
Contributor

Available in v1.18.0

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

Successfully merging a pull request may close this issue.

4 participants