mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 18:17:55 +00:00
pki health-check fails to read in int config values (#19265)
* pki health-check fails to read in int config values
- Go's default behavior when decoding numbers to an interface{} is to use a float64 type which parseutil.SafeParseIntRange does not handle.
- Switch to having the JSON decoder use json.Number which our parseutil library
properly handles.
* Add cl
This commit is contained in:
3
changelog/19265.txt
Normal file
3
changelog/19265.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
cli/pki: Decode integer values properly in health-check configuration file
|
||||||
|
```
|
||||||
@@ -243,13 +243,16 @@ func (c *PKIHealthCheckCommand) Run(args []string) int {
|
|||||||
// Handle config merging.
|
// Handle config merging.
|
||||||
external_config := map[string]interface{}{}
|
external_config := map[string]interface{}{}
|
||||||
if c.flagConfig != "" {
|
if c.flagConfig != "" {
|
||||||
contents, err := os.ReadFile(c.flagConfig)
|
contents, err := os.Open(c.flagConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.UI.Error(fmt.Sprintf("Failed to read configuration file %v: %v", c.flagConfig, err))
|
c.UI.Error(fmt.Sprintf("Failed to read configuration file %v: %v", c.flagConfig, err))
|
||||||
return pkiRetUsage
|
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))
|
c.UI.Error(fmt.Sprintf("Failed to parse configuration file %v: %v", c.flagConfig, err))
|
||||||
return pkiRetUsage
|
return pkiRetUsage
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user