Closed sp185432 closed 5 years ago
Sorry, using {{getv("/bcr/port")}}, not {{getenv("/bcr/port")}}
Keys and values need to be strings in all backends.
Is there any way to pull boolean or integer values to config from backend?
Do you need them as ints and bools or would it be ok to transform the values to strings?
Its ok to be transformed as strings in this requirement.
Also any suggestions if we need to use these as ints and bools?
I think i can try to adjust the file backend so that files like
{
"bcr": {
"port": 3000
}
}
are parseable. Each value would be transformed to its string representation.
We could then, if neccessary, tranform these values back with a filter function (toInt, toBool or something like that).
What do you tink?
Yes, this will be perfectly fine :-)
I experienced this too. After looking at it, I think it's because the nodeWalk function for the file backend has no cases for the other types.
Compare easykv's nodeWalk with confd's:
https://github.com/HeavyHorst/easykv/blob/v1.2.4/file/client.go#L92-L114 https://github.com/kelseyhightower/confd/blob/v0.16.0/backends/file/client.go#L83-L106
confd transforms the value to its string representation so the interface can stay consistent across backends, but it'd be up to the end user to transform them back (if necessary since the values will be rendered as strings in a template anyway).
I just pushed https://github.com/HeavyHorst/easykv/commit/4d4fac1cf46d099faca5eb5c7ea368830a58b4b0 to easyKV. I will update remco in the next few days.
Thanks @HeavyHorst
Remco uses the newest easykv release now. Other types should work now (if you build from master).
Its working thanks.
Great!
Is it possible to add info about this fix to v0.12.0-beta.2 release notes? I started with 'stable' 0.11.1 version and spend about an hour investigating this issue. Already prepared test setup to create new issue but finally found this one.
I added infos to the release notes.
key does not exists for file backend when value is int or boolean
[0000] INFO remco[6]: set file path backend=file filepath=/opt/better_chef_rundeck/bcr.json [0000] ERROR remco[6]: createStageFileAndSync failed: create stage file failed: template execution failed: [Error (where: execution) in /etc/remco/templates/run.sh | Line 5 Col 96 near 'getv'] key does not exist: /bcr/port resource=run.sh.toml [0000] ERROR remco[6]: not all templates could be rendered, trying again after 18 seconds resource=run.sh.toml
Using {{getenv("/bcr/port")}} for value replacement.
My json file bcr.json: { "bcr": { "port": 3000 } }