You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A next stumbling block for this feature is wrong type for value; expected type errors. For example, it seems getenv will always return a string, even if the content in the env var is indeed a valid number.
Unfortunately, template writers for confd are not always in control how how the type in the datastore is set, so whether json or environment vars, getting integers, floats, etc stored as strings is probably common.
The text was updated successfully, but these errors were encountered:
have you any trick to convert string to int with confd 0.14.0
Not me. For docker use cases, the only way I can think to work around it is with an entrypoint script that uses bash, bc, and printf to do the math and set an env var. It's messy because bc has fixed scale format, so printf is needed to reformat the scale (e.g. bc -l has scale of 20, but I don't want bc output with trailing zeros like .500000.... To get 1 / 2 = 0.5:
It's great to see #576 was resolved.
A next stumbling block for this feature is
wrong type for value; expected
type errors. For example, it seemsgetenv
will always return a string, even if the content in the env var is indeed a valid number.Set this env:
And given this template:
The error is
wrong type for value; expected int; got string
results.Looking at https://github.com/hashicorp/consul-template/blob/master/template/funcs.go, one can see they worked past type issues by 'heavier' arithmentic functions using https://golang.org/pkg/reflect/ to do dynamic type conversion.
Unfortunately, template writers for confd are not always in control how how the type in the datastore is set, so whether json or environment vars, getting integers, floats, etc stored as strings is probably common.
The text was updated successfully, but these errors were encountered: