3 ms·
"One line per record, whitespace-delimited fields" is about the physically simplest file-format one can imagine (see: /etc/crontab, /etc/fstab), and that simpli
by thristian 5y ago
"One line per record, whitespace-delimited fields" is about the physically simplest file-format one can imagine (see: /etc/crontab, /etc/fstab), and that simplicity will keep implementation cost and complexity low for the generation script you write.
However, this generation script isn't a complete tool in and of itself; from your description it generates a YAML document which presumably is fed into some downstream system, while upstream you need to accept team names and DB user names among other things. I don't know your tech stack, but I can imagine that there's probably developers who work both upstream and downstream of this file format, with tools in different languages, different transports, different data stores. While it would be possible for every contact-point between different tools and technologies to use the simplest possible format for that interaction, that would generate an explosion of different micro-formats - some without quoting, some with URL encoding or base64 or backslash-escaping or JSON or YAML or ProtoBuf etc. etc. etc.
Instead, to reduce overall system complexity, it can be prudent to stick to one file-format everywhere. Sure, it'll be overkill in some places and nearly-inadequate in others, but the effort spent can pay for itself when everybody touching a file, a parser, or a serialiser knows what to expect and can jump between layers of the tech stack without having to re-learn the quirks of each layer every time. You even leave the door open for automated tools that scan all the config files from all the parts of the system and sanity-check them against each other.
There's an upper-limit too, of course. We don't use JSON encoding for web-pages and images and videos and databases and filesystems, because the benefits of a single standard encoding are outweighed by the drawbacks of JSON for those specific use-cases. But there's a wide span between "JSON is overkill" and "JSON is too primitive" and you can get a lot done in that space.
- oldPete 5y agoThank you for your reply. Code snippet I shared in question is literally the logic (removing the bash function definition of course which does nothing but writes value of specified variables, and repetitive per db-user lines), not some pseudo-code. There is no up/down stream. one needs to add/update/remove a tuple when a user is added/updated/removed. I am just generating alert definitions which will be used by prometheus/ alertmanager (without any further processing what so ever), where team names and DB user names among other things are being edited manually, and will be same way for a long time unless a major overhaul of full system happens. And there is no other developer editing code, depending/ dependent on this script/ yml from any other part of the system. I would have used format in use already, if there was any other system interaction (completely aligned with "reduce overall system complexity").