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

Allow username and password to be passed into register with flags #401

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

Westwooo
Copy link
Contributor

By default the cb-env register command prompts for the user name and password to be entered after running the command, allowing the password to be hidden. We should support passing the username and password in using flags to allow registering multiple clusters without having to repeatedly enter the same username and password.

Copy link

@mattyhall mattyhall left a comment

Choose a reason for hiding this comment

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

LGTM

src/cli/util.rs Outdated Show resolved Hide resolved
src/cli/util.rs Outdated Show resolved Hide resolved
@Westwooo Westwooo force-pushed the flags_for_creds_cbenv_register branch from a344428 to ca1259a Compare August 22, 2024 13:29
let password = password_flag.map_or_else(
|| match rpassword::prompt_password("Password: ") {
Ok(p) => {
if p.is_empty() {

Choose a reason for hiding this comment

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

Doesn't look like the original code had this check, is it needed?
I assume there could be cases where we don't want to include a password at all (e.g. when using certs). Does this check get avoided for those cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original code didn't have this check as I thought that prompt_password returned an error on am empty password, but it does not.

Even when using certs cbshell needs the username and password to perform any doc ops. Also when we register a cluster through the config file we return an error if there is no username and password, so I think it should be the same when registering a cluster through this command.

The other place this is used is when creating credentials, where we obviously need a username and password. I think if there was something that used wither certs or username/password it'd be the responsibility of the caller to call this func if they require a username and password, and don't if a cert has been supplied.

Choose a reason for hiding this comment

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

Thanks for the context, makes sense.

@Westwooo Westwooo merged commit 19dec4c into main Aug 23, 2024
11 checks passed
@Westwooo Westwooo deleted the flags_for_creds_cbenv_register branch August 23, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants