mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 02:02:43 +00:00
backport of commit 9c4e65986f (#19273)
Co-authored-by: Steven Clark <steven.clark@hashicorp.com>
This commit is contained in:
committed by
GitHub
parent
4bb0139dd6
commit
88e9f55199
3
changelog/19269.txt
Normal file
3
changelog/19269.txt
Normal file
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user