Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 3839205

Browse files
committed
Allows the use of float values in environment variables
When converting a docker-compose file with float values as environment variables, libcompose errors out. Example: ``` version: "2" services: redis: image: redis:3.0 environment: foo: 0.3 ``` Errors out with: `Cannot unmarshal '0.3' of type float64 into a string value` This commit fixes the issue by detecting if a float value has been passed and successfully converting it to a string variable. Signed-off-by: Charlie Drage <charlie@charliedrage.com>
1 parent 5cba167 commit 3839205

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

yaml/types_yaml.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ func toSepMapParts(value map[interface{}]interface{}, sep string) ([]string, err
217217
parts = append(parts, sk+sep+strconv.Itoa(sv))
218218
} else if sv, ok := v.(int64); ok {
219219
parts = append(parts, sk+sep+strconv.FormatInt(sv, 10))
220+
} else if sv, ok := v.(float64); ok {
221+
parts = append(parts, sk+sep+strconv.FormatFloat(sv, 'f', -1, 64))
220222
} else if v == nil {
221223
parts = append(parts, sk)
222224
} else {

0 commit comments

Comments
 (0)