From 5416e18007c765deb3e99efa572c8075cbb540de Mon Sep 17 00:00:00 2001 From: Miro Prasil Date: Mon, 18 Oct 2021 08:29:34 +0100 Subject: [PATCH] vmctl influx convert bool to number (#1714) vmctl: properly convert influx bools into integer representation When using vmctl influx, the import would fail importing boolean fields with: ``` failed to convert value "some".0 to float64: unexpected value type true ``` This converts `true` to `1` and `false` to `0`. Fixes #1709 --- app/vmctl/influx/parser.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/vmctl/influx/parser.go b/app/vmctl/influx/parser.go index e8b425f422..5cd5a374c3 100644 --- a/app/vmctl/influx/parser.go +++ b/app/vmctl/influx/parser.go @@ -58,6 +58,12 @@ func toFloat64(v interface{}) (float64, error) { return float64(i), nil case string: return strconv.ParseFloat(i, 64) + case bool: + if i { + return 1, nil + } else { + return 0, nil + } default: return 0, fmt.Errorf("unexpected value type %v", i) }