-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Issues with formats other than YAML #967
Comments
FWIW. A TOML file also fails:
|
First things first: To be honest, I'm not really familiar with HCL (other than using it in terraform), but looking at your example, it seems your snippet is translated into this:
Notice that the value of You can get the original value using I'd recommend choosing another format, until it's sorted out. As for TOML: your example is invalid: you need to quote strings: [host]
address = "localhost"
port = 5799 Also, make sure to properly set the config name and type. TOML works just fine for me with the above example. Let me know if it helps. |
@spf13 hey, I wanted to check-in and see if this is simply a lower-priority item, or there is some fundamental issue that prevents this to get fixed? Thanks! |
@AutomationD please see my answer above. TL;DR HCL (or at least the implementation) is fundamentally broken and will be removed from Viper 2. |
@sagikazarmark Hey, thanks for your response. So I'm curious what is stopping us to ensure the traversal is done considering the extra slice in-between maps? |
I wouldn't want to add that kind of behavior to the config lookup, just to handle the quirks of HCL when it's not actually a popular option. Once encoding/decoding is properly factored out from the Viper core, I don't mind doing any additional steps to make up for HCL's weird behavior. See #1167. |
Good point. Thanks! What would be the top preferred formats to use with viper right now? |
Yaml or json both work quite well. |
Where do you see TOML in this list? would it be kept as a first-class citizen? |
I think so. |
I've been trying a few different config formats to see how they differ. For example,
with config file ./example.hcl as
The output is empty:
If I try this with ./example.yaml (and make the two hcl to yaml changes in the code) everything works:
Is this a bug or is there some nature of using HCL/TOML/etc. that I'm missing? FWIW only YAML appears to work properly when embedded this way. If I use a simple HCL file of (and, again, make appropriate code changes)
then the address and port values are output correctly.
The text was updated successfully, but these errors were encountered: