-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix(cmd/influx): allow for creating users without initial passwords in influx user create
#20657
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't sure if we should try to set the Org if we can't set the password, but maybe that's correct (saving the user another redo step when they set the password).
Minor point anyway.
cmd/influx/user.go
Outdated
pass := b.password | ||
if orgID == 0 && pass == "" { | ||
return b.printUser(userPrintOpts{user: user}) | ||
orgID, setOrgErr := b.org.getID(dep.orgSvc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to bail earlier (i.e., here) if setPassErr != nil, and not try to set the Org?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll restore the previous bail-out order (org first if ID is specified, then password). Better to not rock the boat too much on a patch release.
cmd/influx/user.go
Outdated
} | ||
|
||
if pass != "" && orgID == 0 { | ||
return errors.New("an org id is required when providing a user password") | ||
if setPassErr != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this above the attempt to set the organization.
152298d
to
7945461
Compare
influx user create
c256321
to
a03324e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks clean and clear.
Closes #20645
I manually tested the case of setting a password without specifying an org, it's tough to unit-test because the org-flag helpers are coded to read a global config file as a fallback when no flags are passed in.