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 listing health checks without mount path #19199

Merged
merged 2 commits into from
Feb 15, 2023

Conversation

cipherboy
Copy link
Contributor

This allows the bare:

$ vault pki health-check -list

without a corresponding mount path to complete. Otherwise, users would be greeted with a prompt for the mount, which is less than ideal.

This allows the bare:

    $ vault pki health-check -list

without a corresponding mount path to complete. Otherwise, users would
be greeted with a prompt for the mount, which is less than ideal.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
@cipherboy cipherboy added bug Used to indicate a potential bug pr/no-changelog backport/1.13.x labels Feb 15, 2023
@cipherboy cipherboy added this to the 1.13.0 milestone Feb 15, 2023
// When listing is enabled, we lack an argument here, but do not contact
// the server at all, so we're safe to use a hard-coded default here.
pkiPath := "pki"
if len(args) == 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we invert this to be specific to c.flagList is set to ignore/use "pki", I think that would be a little more intuitive in the future (basically we ignore the mount arg when c.flagList is set?)

Also there is a call out above around line 138 within the c.flagList's usage that says it still requires a positional mount argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good catch.

I'm not sure I follow how we'd avoid the array-out-of-bounds access?

pkiPath := args[0] // would crash, no?
if c.flagsList {
    pkiPath = "pki"
}

I think we're at the equivalent:

pkiPath := "pki" // or <mount> or some other sentinel.
if !c.flagsList { // == len(args) == 1
    pkiPath = args[0]
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah fair enough, seeing it in code now, it would amount to the same thing, I had been thinking of an if/else scenario but the comment + current code is good.

I'd just request we fix up the usage above then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you!! Pushed :-)

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Copy link
Contributor

@stevendpclark stevendpclark left a comment

Choose a reason for hiding this comment

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

👍

@cipherboy cipherboy enabled auto-merge (squash) February 15, 2023 18:40
@cipherboy cipherboy merged commit 100ec9a into main Feb 15, 2023
@cipherboy cipherboy deleted the cipherboy-minor-improvements-health-check branch April 21, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug pr/no-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants