| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
|
I'm not familiar with this format. Do you have any examples of storing hashmap data in env var values like this in the wild? If possible I'd like to align with existing conventions |
Sorry, something went wrong.
|
Hmm, the only examples I saw they use kind of JSON syntax like: export MY_VALUE="{key: value, key2: value2}". Do you prefer this format ? |
Sorry, something went wrong.
|
What is like to avoid is inventing a new syntax for env variables Can you link me to some example of those tools? |
Sorry, something went wrong.
|
In https://github.com/spf13/viper for example they support json syntax but also this kind of syntax: struct Cfg {
test: HashMap<String, String>,
}You can have some kind of export TEST_KEY="value" and export TEST_KEY2="value2" but I think we can't do in this way for envy. Maybe I'm wrong ? |
Sorry, something went wrong.
|
In Javascript they also use JSON syntax as I see on stackoverflow. But TBH I didn't really find a lot of informations about this kind of issue. I think it's not very frequent |
Sorry, something went wrong.
|
I'm wondering if it might be more useful to assume less about the structure of values and just treat structured data as serde::Serialize types. Env vars place a design constraint that you represent data as flat keys and values. That's what's currently exposed in envy. For specialized needs I can see a setup as follows Serialize a special value as a plain string in an env var then in an impl method, use a serde deserializer of your choice to deseriaze additional data from_str. In your case that might be json. In this case envy doesn't need to change and you have maximum flexibility to encode extra structure in what ever format you like. |
Sorry, something went wrong.
Prefixed var names are supported but carry a different but common convention. They namespace vars targeting an application |
Sorry, something went wrong.
|
I fully understand your concerns. And I am partially agree. What disturbing me is the fact that we support Vec and not HashMap and as HashMap is part of the std lib it's common to implement a default Deserialize implementation. The main issue here is that everytime we want to deal with HashMap it means we must create our own custom type to wrap HashMap and be able to implement Deserialize on it. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Hello, I wanted to add support of hashmap inside environment variable. I suggest this kind of syntax: export FOO="{key:value, key2:value2}"
I'm open to any suggestions :)