<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">I have come up with solutions to a couple of these which look a little different to what you’re doing:</div><div class=""><br class=""></div>2: I’ve often solved this by encoding config environment variables first into json, and then into base64. You get your booleans, hashes, or array of integers out like so: MultiJson.load(Base64.decode64(ENV[‘my_var’])). Json has always been enough for me to describe my config and you don’t have to do any manual parsing at all.<div class=""><div class=""><br class=""></div><div class="">5 + 6: In the past, I’ve solved this problem by declaring a list of expected environment variables in an initializer (maybe you can get your list directly out of your config wrapper?). You can check if the variables are nil on startup and if they are you can raise an error. This will prevent your app from starting so you know immediately if there were any disconnects between defined environment variable names and expected ones.</div><div class=""><br class=""></div><div class="">I know that’s not an answer to your main question but you might find those ideas useful.</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 27/02/2019, at 10:52, Patrick Gleeson <<a href="mailto:patrick.c.gleeson@gmail.com" class="">patrick.c.gleeson@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class="">Hi LRUG,<div class=""><br class=""></div><div class="">After the awesome discussion on 'Continuous *' back in January, I wondered if this might be a place to ask another broad question I've been mulling for a while now.</div><div class=""><br class=""></div><div class="">According to the 12 factor app (<a href="https://12factor.net/config" class="">https://12factor.net/config</a>) we should store our config in environment variables, and in Ruby that means we access it via ENV. I get the benefit of orthogonal config, but ENV always ends up feeling pretty unsatisfactory to me for config-heavy apps, for the following reasons:</div><div class=""><br class=""></div><div class="">(1) No easy way of seeing for any app what config needs to be set (cmd-shift-F 'ENV' anyone?)</div><div class="">(2) Everything is stringly typed (How many times have I forgotten that 'false' is truthy? And what if a config var is going to be, say, either an array of integers or null? "&.split(',')&.map(:to_i)" is not my favourite thing.)</div><div class="">(3) No single place to put sensible defaults if an environment variable not set</div><div class="">(4) No namespacing or grouping except by prefixes</div><div class="">(5) No protection from typos when reading env vars</div><div class="">(6) Or when writing them</div><div class="">(7) No fine-grained access control to env vars (occasionally useful if someone semi-technical wants direct control over something set in config but you don't want them touching the database credentials)</div><div class="">(8) Depending on where you deploy to, your UI for reading and writing env vars may be better or worse</div><div class="">(9) Depending on where you deploy to, your mechanism for cloning an environment's vars may be better or worse</div><div class="">(10) No revision history ("Hey Patrick, can we go back to using that redirect we were using last week?")</div><div class=""><br class=""></div><div class="">For 1 - 5 I normally end up writing a wrapper around ENV with a little DSL to define the keys the app uses, so that I end up with file with a list of things like:</div><div class=""><br class=""></div><div class=""><font face="monospace, monospace" class="">namespace :fulfilment_centre do</font></div><div class=""><font face="monospace, monospace" class="">  set :hours_of_operation, type: :integer, array: true, default: [9,17]<br class=""></font></div><div class=""><font face="monospace, monospace" class="">end</font></div><div class=""><br class=""></div><div class="">And then I can call <font face="monospace, monospace" class="">Config.fulfilment_centre.hours_of_operation</font> with some confidence</div><div class=""><br class=""></div><div class="">But I don't really know how best to get round 6 - 10. I sort of feel like I want a Config-as-a-Service platform with web/RESTful interfaces for defining environments and their config, so that my apps can pull in config on deploy. Does something like that exist? Or (more likely, I would imagine) do I want the wrong thing? And if so why?</div><div class=""><br class=""></div><div class="">Any thoughts welcome!</div><div class=""><br class=""></div><div class="">Best,</div><div class=""><br class=""></div><div class="">Patrick</div></div></div></div>
_______________________________________________<br class="">Chat mailing list<br class=""><a href="mailto:Chat@lists.lrug.org" class="">Chat@lists.lrug.org</a><br class="">Archives: http://lists.lrug.org/pipermail/chat-lrug.org<br class="">Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org<br class="">List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org<br class=""></div></blockquote></div><br class=""></div></div></body></html>