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
This commit is contained in:
Miro Prasil 2021-10-18 08:29:34 +01:00 committed by Aliaksandr Valialkin
parent 0e1dbcd039
commit c0853d4bf8
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -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)
}