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

feat: allow role updates to token using cli #23479

Closed

Conversation

burnerlee
Copy link

This PR adds the following flag functionality to nomad acl token update to allow users to update token roles:

  1. -role-id
  2. role-name

Fixes: #18354

Copy link
Contributor

@pkazmierczak pkazmierczak left a comment

Choose a reason for hiding this comment

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

Hey @burnerlee, this looks great, thanks a lot for contributing! I left some comments, but nothing major.

Would you also add a changelog message? Something like:

release-note:improvement
cli: Allow role updates to token

(you can use make cl command to generate it)

@@ -70,6 +79,14 @@ func (c *ACLTokenUpdateCommand) Run(args []string) int {
policies = append(policies, s)
return nil
}), "policy", "")
flags.Var((funcVar)(func(s string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be great to have these in AutocompleteFlags() method, too (with complete.PredictAnything)

@@ -111,6 +128,11 @@ func (c *ACLTokenUpdateCommand) Run(args []string) int {
token.Policies = policies
}

roles := generateACLTokenRoleLinks(c.roleNames, c.roleIDs)
if len(roles) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we should also check whether there are any roleIDs set? perhaps len(roles) != 0 || len(ids) != 0?

Copy link
Contributor

Choose a reason for hiding this comment

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

also perhaps move the check before calling generateACLTokenRoleLinks?

@pkazmierczak pkazmierczak self-assigned this Jul 2, 2024
@pkazmierczak
Copy link
Contributor

ah one more thing: could you update the documentation to include these new flags, too? https://github.com/hashicorp/nomad/blob/main/website/content/docs/commands/acl/token/update.mdx

@pkazmierczak pkazmierczak added backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/1.8.x backport to 1.8.x release line labels Jul 2, 2024
@tgross
Copy link
Member

tgross commented Aug 8, 2024

Sorry, it looks like we had a PR in-flight for this which got abandoned, and I didn't notice that we had this open when I carried that PR. I'm going to close this in lieu of #18532. My apologies @burnerlee!

@tgross tgross closed this Aug 8, 2024
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/1.8.x backport to 1.8.x release line
Projects
Development

Successfully merging this pull request may close these issues.

[cli] Allow "role" updates to tokens
3 participants