Add support for JSON configuration files#715
Conversation
Signed-off-by: Dan Rumney <[email protected]>
Signed-off-by: Dan Rumney <[email protected]>
Signed-off-by: Dan Rumney <[email protected]>
Signed-off-by: Dan Rumney <[email protected]>
There was a problem hiding this comment.
I don't know if these new integration tests really provide much extra coverage. Your change is appropriately isolated to just one module. A single integration test of that module (showing that a json file is read and returns the expect dict), should be sufficient.
The test suite is pretty slow as it is, we should avoid making it slower unless the tests actually add new coverage.
There was a problem hiding this comment.
Agreed - this file will be removed
|
I'm a big fan of YAML. Being able to add comments, and cleaner syntax is huge. I understand there are some gotchas, but it's so prevalent now, that you learn them pretty quick. That said, I'm not against adding this support. I think it's a small enough change, and I understand everyone doesn't share my appreciation for YAML. |
|
I really miss the the ability to add comments :) However, our environment is heavily biased towards Node and being able to operate on JSON files is much more convenient that YAML files. I'm pretty confident that YAML/JSON won't result in a bifurcation of your code (which is the biggest risk from adding support for a secondary input format). I think this code converts to a Python structure early enough that your code will be safe. |
…age of unit test Signed-off-by: Dan Rumney <[email protected]>
Signed-off-by: Dan Rumney <[email protected]>
|
Updates made and build is passing |
|
Interesting. I can see an argument for supporting JSON in that it makes it easier to generate configuration files, but then I'm not sure if that's something we want to encourage. (What's your use case, and would it be equally well served by an import mechanism and/or parameterisation of configuration values?) Thanks for the contribution - I need to think about it some more. |
|
I'm +1 on having JSON as an alternative format. I fully understand the advantage of YAML (comments and cleaner, more human readable). JSON is natively supported by just about any language, so for automated generation and/or editing of a Fig-stack definition, I think this is a big win.
All examples in the documentation can keep using YAML, to emphasise it's the "standard" format. An extra section / note "alternative formats" can be added to show that JSON is also supported. |
|
JSON is a subset of YAML so this should already work out of the box with the current YAML parser. |
|
Parsing the file is actually the smallest part of this change. |
|
👍 for JSON configs for reasons like this: |
|
Since the Yaml parser supports JSON documents I'm reluctant to make any code changes here. It might be worth mentioning in the docs that you can use JSON, it's just "not considered a supported feature, even thought it should work in most cases". |
|
This will be documented in #2291 |
Co-authored-by: Gavin Kelly <[email protected]>
I switched over to crane because of a Fig issue and have invested heavily in JSON configuration files.
I'd like to start using Fig again, but switching from JSON to YAML will be a pain.
It seems pretty trivial for Fig to support JSON as well as YAML for input file format. Thence this Pull Request.