Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key does not exists for file backend when value is int or boolean #33

Closed
sp185432 opened this issue Oct 28, 2019 · 15 comments
Closed

key does not exists for file backend when value is int or boolean #33

sp185432 opened this issue Oct 28, 2019 · 15 comments

Comments

@sp185432
Copy link

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

@sp185432
Copy link
Author

Sorry, using {{getv("/bcr/port")}}, not {{getenv("/bcr/port")}}

@HeavyHorst
Copy link
Owner

Keys and values need to be strings in all backends.

@sp185432
Copy link
Author

sp185432 commented Oct 28, 2019

Is there any way to pull boolean or integer values to config from backend?

@HeavyHorst
Copy link
Owner

Do you need them as ints and bools or would it be ok to transform the values to strings?

@sp185432
Copy link
Author

Its ok to be transformed as strings in this requirement.

Also any suggestions if we need to use these as ints and bools?

@HeavyHorst
Copy link
Owner

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?

@sp185432
Copy link
Author

Yes, this will be perfectly fine :-)

@andreykaipov
Copy link
Contributor

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).

@HeavyHorst
Copy link
Owner

I just pushed HeavyHorst/easykv@4d4fac1
to easyKV. I will update remco in the next few days.

@sp185432
Copy link
Author

Thanks @HeavyHorst

@HeavyHorst
Copy link
Owner

Remco uses the newest easykv release now. Other types should work now (if you build from master).

@sp185432
Copy link
Author

sp185432 commented Nov 2, 2019

Its working thanks.

@HeavyHorst
Copy link
Owner

Great!

@hatifnatt
Copy link

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.

@HeavyHorst
Copy link
Owner

I added infos to the release notes.

@freeseacher freeseacher mentioned this issue Jul 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants