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

Backport of Allow listing health checks without mount path into release/1.13.x #19203

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions command/pki_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ default unless enabled by the configuration file explicitly.`,
Default: false,
EnvVar: "",
Usage: `When specified, no health checks are run, but all known health
checks are printed. Still requires a positional mount argument.`,
checks are printed.`,
})

return set
Expand Down Expand Up @@ -170,10 +170,10 @@ func (c *PKIHealthCheckCommand) Run(args []string) int {
}

args = f.Args()
if len(args) < 1 {
if !c.flagList && len(args) < 1 {
c.UI.Error("Not enough arguments (expected mount path, got nothing)")
return pkiRetUsage
} else if len(args) > 1 {
} else if !c.flagList && len(args) > 1 {
c.UI.Error(fmt.Sprintf("Too many arguments (expected only mount path, got %d arguments)", len(args)))
for _, arg := range args {
if strings.HasPrefix(arg, "-") {
Expand All @@ -196,7 +196,14 @@ func (c *PKIHealthCheckCommand) Run(args []string) int {
return pkiRetUsage
}

mount := sanitizePath(args[0])
// 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 := "<mount>"
if len(args) == 1 {
pkiPath = args[0]
}

mount := sanitizePath(pkiPath)
executor := healthcheck.NewExecutor(client, mount)
executor.AddCheck(healthcheck.NewCAValidityPeriodCheck())
executor.AddCheck(healthcheck.NewCRLValidityPeriodCheck())
Expand Down