TOML is a bad file format for human configuration. For example, in the following file [hosts] "example.org" = "localhost:8000" "foo.com" = "localhost:9000" "sub.example.com" = "localhost:9002" certfile = "path/to/cert.pem" keyfile = "path/to/key.pem" Ordinary human readers would generally think that the hosts table has 3 entries. But TOML considers certfile and keyfile to also be entries in the hosts table. TOML has…
I’ve always liked yaml but I feel the world is moving towards toml. Keen to see more of toml issues to build a fair comparison
Use TOML for `.env` Files?
31–40 of 64 posts
Re: Use TOML for `.env` Files?
#32Earlier quoted context omitted.
Why would you want to require a specific order in the resulting object representation? If you need ordering, use arrays. And if you need to do stuff like content signatures, it makes sense to use some form of normalizer anyway (e.g. alphabetic key order).
There isn't a need for specific ordering of keys in the object representation. But I want to be able to write parts of the toml document in different orders (e.g. "hosts" table before "certfile"; or "hosts" table after "certfile") and still have the same effective object.
Apache configs are my personal favourite hate subject here.
Re: Use TOML for `.env` Files?
#33TOML is a bad file format for human configuration. For example, in the following file [hosts] "example.org" = "localhost:8000" "foo.com" = "localhost:9000" "sub.example.com" = "localhost:9002" certfile = "path/to/cert.pem" keyfile = "path/to/key.pem" Ordinary human readers would generally think that the hosts table has 3 entries. But TOML considers certfile and keyfile to also be entries in the hosts table. TOML has…
I’ve always liked yaml but I feel the world is moving towards toml. Keen to see more of toml issues to build a fair comparison
Re: Use TOML for `.env` Files?
#34I find the Twelve-Factor App's design to use environment variable for configuration ( https://12factor.net/config ) unintuitive and perhaps a bad design choice. I believe environment variables are bad for the same reasons global variables are bad. Pros listed for env vars include not committing them to the repo and not encouraging grouping them together as environments such as dev, staging or prod. I don't agree that…
Files are written to disk. In a cloud setup that mean possibly leaking credentials when your disk is re-assigned to another tenant. Yes, cloud provider are supposed to properly erase hard drive before reassigning. Can you be 100% sure they do though ? With environment variable in RAM the problem is moot. Committing and/or generating .env in production system is completely missing the point.
Re: Use TOML for `.env` Files?
#35I find the Twelve-Factor App's design to use environment variable for configuration ( https://12factor.net/config ) unintuitive and perhaps a bad design choice. I believe environment variables are bad for the same reasons global variables are bad. Pros listed for env vars include not committing them to the repo and not encouraging grouping them together as environments such as dev, staging or prod. I don't agree that…
Files are written to disk. In a cloud setup that mean possibly leaking credentials when your disk is re-assigned to another tenant. Yes, cloud provider are supposed to properly erase hard drive before reassigning. Can you be 100% sure they do though ? With environment variable in RAM the problem is moot. Committing and/or generating .env in production system is completely missing the point.
I sometimes find secrets to be safer inside config files since so many times the environment variables get dumped into logs – hence all the popular CI/CD products have features to try to scrub such secrets from their logs.
I agree about not using .env files in production, I'd not use it at all.
Re: Use TOML for `.env` Files?
#36I always treated .env files as "this is the current set of environment variables", containing just NAME="value" pairs. If there are _different_ sets of variables, they should not be in that file, but in some different place, like the suggested settings.toml. Or perhaps use a bunch of different files in .envs/whatever.env and symlink them. Let's not make everything complicated :)
Hear hear! The author claims "There is no standard" but I think the standard is so simple it hasn't been written down. The standard is what you said, KEY="value" and that's it. Simple, easy to parse, fast and compatible with how environment variables are declared in `/etc/environment` since forever. Having different .env files for different OSes is easy as well. You have one `.env` that provides the default values, t…
Here's a line of bash code that sets the variable X to a single-quote character:
X=''\'''
(lest you think that's an unduly obtuse way to do it, this is what `git rev-parse --sq-quote` does! If not 'best practice' it's surely at least 'practice that's gotta be supported'!)Here's what python-dotenv gets:
Python-dotenv could not parse statement starting at line 1
Similarly, when you use python-dotenv to set a key with the value containing only the single quote dotenv.set_key('.env', 'X', "'")
the file is not acceptable to bash: bash: .env: line 1: unexpected EOF while looking for matching `''Re: Use TOML for `.env` Files?
#37Earlier quoted context omitted.
And the nice thing about those NAME="value" pairs is you can now source it directly in shells, or read it with some straight forward, usually built in library in many programming languages and supporting tools
Until the value has a bang or any other special character that ends up being expanded by the shell and wasting half a day finding it!
Just how large are your env files?
Re: Use TOML for `.env` Files?
#38The author mentions .env files come from 12factor design, but the 12factor way is just using environment variables directly for configuration.., Environment variables by themselves are language/library agnostic by design and aren't supposed to be cross-platform by design (they're meant to be tied to the "environment" which includes OS) If you're storing config in a .env file that's read directly by your application (…
If you name it .env it's much easier to setup source control rules to exclude .env files. If you name them say .config, then you increase the chances of accidentally leaking creds (by checking them into the repo).
Re: Use TOML for `.env` Files?
#39Environment variables existed long before web apps did. And you are supposed to source the .env file to set the variables in the environment. You don't parse them yourself. You call `getenv()` to get the value for your current environment.
Re: Use TOML for `.env` Files?
#40The author mentions .env files come from 12factor design, but the 12factor way is just using environment variables directly for configuration.., Environment variables by themselves are language/library agnostic by design and aren't supposed to be cross-platform by design (they're meant to be tied to the "environment" which includes OS) If you're storing config in a .env file that's read directly by your application (…