Support config values to have object types
Hi, I'd like to be able to do something like
aliases:
etc/spec:
type: "object"
cli:
commands:
- foo
Where aliases is an object in the aeson sense - a hashmap that may change between configurations. It is naturally impractical to supply an hashmap via environment variable or command line so this would be file config only. Any thoughts?
It is naturally impractical to supply a hashmap via environment variable or command line so this would be file config only. Any thoughts?
That's correct, not sure if we fail when specifying an env or a cli entry when the type is object, I think we should.
So, you want the entry to be defined in the file configuration map only if the command is foo?
The cli.command setting does not do any enforcement, it's data is used to generate the CLI command of your program.
I think you can do a type: "object" without the cli and it should work. Is it not the case?
If I just do
aliases:
etc/spec:
type: "object"
I get the error
InvalidConfiguration Nothing "Error in $['etc/entries'].aliases.type: expected ConfigValueType (string, number, bool), encountered String"
Wondering what version of etc are you using, is it 0.4.3.0?
0.4.0.3 I assume you mean, but yep
Ok, after going through the code and understanding what is going on, I came to the fact that I did not add this functionality on purpose, given that I always wanted my objects to have a shape on configuration definition.
I added the possibility to have an array of objects as a type (e.g. [object]), because I needed a list of objects, but didn't go through the single object definition.
This is a missing feature that needs to be added.
Requirements
- Allow the
type: objectin etc - Make sure that the parser fails when having a
type: objectwhencliorenvoptions are given (as there is no sensitive way to get this values from those inputs) - Tests that validate functionality in the
SpecTest.hsfile
I'll be able to get to this over the weekend, if you feel like you want to tackle it, that would be awesome, I can tell you everything start with changes here
Thanks, I had an attempt but it's not clear to me what else I'm supposed to change.