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 Output default config output from pki health-check --list as json into release/1.13.x #19273

Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions changelog/19269.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
cli/pki: Change the pki health-check --list default config output to JSON so it's a usable configuration file
```
21 changes: 10 additions & 11 deletions command/pki_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,19 @@ func (c *PKIHealthCheckCommand) Run(args []string) int {

// Handle listing, if necessary.
if c.flagList {
c.UI.Output("Health Checks:")
c.UI.Output("Default health check config:")
config := map[string]map[string]interface{}{}
for _, checker := range executor.Checkers {
c.UI.Output(" - " + checker.Name())

prefix := " "
cfg := checker.DefaultConfig()
marshaled, err := json.MarshalIndent(cfg, prefix, " ")
if err != nil {
c.UI.Error(fmt.Sprintf("Failed to marshal default config for check: %v", err))
return pkiRetUsage
}
c.UI.Output(prefix + string(marshaled))
config[checker.Name()] = checker.DefaultConfig()
}

marshaled, err := json.MarshalIndent(config, "", " ")
if err != nil {
c.UI.Error(fmt.Sprintf("Failed to marshal default config for check: %v", err))
return pkiRetUsage
}

c.UI.Output(string(marshaled))
return pkiRetOK
}

Expand Down