1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 12:45:21 +01:00

Also parse floating point numbers if they represent integers.

Signed-off-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Felix Fontein
2025-07-28 22:08:10 +02:00
parent c30e36ea76
commit df09e2c119

View File

@@ -248,8 +248,15 @@ func DecodeNonStrings(m map[string]interface{}) error {
case string:
vInt, err := strconv.Atoi(val)
if err != nil {
// Older versions of SOPS stored shamir_threshold as a floating point representation
// of the actual integer. Try to parse a floating point number and see whether it
// can be converted without loss to an integer.
vFloat, floatErr := strconv.ParseFloat(val, 64)
vInt = int(vFloat)
if floatErr != nil || float64(vInt) != vFloat {
return fmt.Errorf("shamir_threshold is not an integer: %s", err.Error())
}
}
m["shamir_threshold"] = vInt
case int:
m["shamir_threshold"] = val