Skip to content

Commit

Permalink
backport of commit 4ea5c58 (hashicorp#19268)
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 e53ac26 commit 8ffa334
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog/19265.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
cli/pki: Decode integer values properly in health-check configuration file
```
7 changes: 5 additions & 2 deletions command/pki_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,16 @@ func (c *PKIHealthCheckCommand) Run(args []string) int {
// Handle config merging.
external_config := map[string]interface{}{}
if c.flagConfig != "" {
contents, err := os.ReadFile(c.flagConfig)
contents, err := os.Open(c.flagConfig)
if err != nil {
c.UI.Error(fmt.Sprintf("Failed to read configuration file %v: %v", c.flagConfig, err))
return pkiRetUsage
}

if err := json.Unmarshal(contents, &external_config); err != nil {
decoder := json.NewDecoder(contents)
decoder.UseNumber() // Use json.Number instead of float64 values as we are decoding to an interface{}.

if err := decoder.Decode(&external_config); err != nil {
c.UI.Error(fmt.Sprintf("Failed to parse configuration file %v: %v", c.flagConfig, err))
return pkiRetUsage
}
Expand Down

0 comments on commit 8ffa334

Please sign in to comment.