Skip to content

Commit

Permalink
backport of commit 9c4e659 (hashicorp#19273)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Clark <steven.clark@hashicorp.com>
  • Loading branch information
1 parent 4bb0139 commit 88e9f55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
3 changes: 3 additions & 0 deletions changelog/19269.txt
@@ -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
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

0 comments on commit 88e9f55

Please sign in to comment.