-2

From the 12-factors, III Config:

A litmus test for whether an app has all config correctly factored out of the code is whether the codebase could be made open source at any moment, without compromising any credentials.

but then...

Another approach to config is the use of config files which are not checked into revision control, such as config/database.yml in Rails. This is a huge improvement over using constants which are checked into the code repo, but still has weaknesses: it’s easy to mistakenly check in a config file to the repo; there is a tendency for config files to be scattered about in different places and different formats, making it hard to see and manage all the config in one place.

Our system is a bunch of microservices. Each microservice is an "app", per 12-factor. I like the idea of being in the mindset that we could decide on a whim to open source one of them and we should be able to do so because it keeps us accountable; codecov, being responsible about secrets in code and being as frictionless as one can be when onboarding newcomers..

But an open-source component should be easy to run and demo. How can Jack from the other side of the world, run and demo our open source component he just cloned, if i don't check at least an .env that describes required ports etc?

I find READMEs of the type:

"Wait.. wait.. before you run this, do X on port Y...oh and also this, and also that".

to be in bad taste.

PS: This question is similar but not a dupe. The OP could use something like Vault and get it over with; that's not an option here.

12
  • 2
    put the test config in source control. override with environment specific config (from vault/keystore/deployment system) when you deploy
    – Ewan
    Commented Apr 28 at 13:16
  • What the author is saying is that using .env files encourages internal contributors to eventually jam secrets in them which at some point they'll then push up to souce control. My immediate thought is that that's a bunch of overthought crap, but I've managed to amaze myself once again by doing the exact same thing in about 2-3 hours. Commented Apr 28 at 13:27
  • 3
    I don't understand the problem. Why is using a vault not an option here? Check in a blank or development .env file that doesn't have meaningful secrets in it that would either require someone to set well-defined options or run the service in a development mode. I think your stance of "open-source should be easy to run and demo" is putting too many constraints on potential solutions and isn't a well-recognized truthful statement.
    – Thomas Owens
    Commented Apr 28 at 13:30
  • 2
    I'm closing this question, then. It doesn't appear to be in good faith. Polls aren't appropriate here. Unless you can elaborate on the statement that a requirement of open-source is "easy to run and demo" and also on why vaults are not an option, I don't see a real question about a real problem.
    – Thomas Owens
    Commented Apr 28 at 13:33
  • 2
    I stand by the decision. Either edit the question or start a discussion on Meta. Based on your comments, I don't believe that this is a good-faith question about a problem that you are actually having. Unless you can elaborate on the characteristics problem, I don't see a reason to allow people to post things that cannot be judged based on their ability to solve the problem.
    – Thomas Owens
    Commented Apr 28 at 13:38

2 Answers 2

2

Here's the possible options I can see:

  • Include a configuration script (that is checked in) that builds a config file pointing to your demo environment. This could also prompt the user if they want to initialize their own environment instead. Instructions would suggest running this on first install.
  • Hard code defaults into the app that point to your demo. If no config file is found, use those defaults.
  • If on first run, no config file is found, build one pointing to the demo.
  • Include a default config file that is checked in and points to the demo. This could include (commented out?) templates for the user to customize. (maybe call it env.dist? to be copied to .env which is listed in .gitignore)
  • Use a tiered config file system that allows higher priority config files to override all or part of lower priority config files. Highest priority config files would be local and outside of your repo. The lowest priority config file would be checked in and point to your demo. Then the demo config would be used if all the rest were not found.
4
  • Thanks, this is good. I (personally) have found a better answer here. Commented Apr 28 at 16:03
  • The idea of a .dist file mentioned in the other answer is along the same lines as what I was thinking in several of the solutions above, so I've expanded that.
    – user10489
    Commented May 1 at 3:43
  • Oh no, not that answer, I meant here: stackoverflow.com/questions/43664565/… Commented May 1 at 16:00
  • Yes, that too. I just didn't mention gitignore and saw no point in rehashing your fine coverage.
    – user10489
    Commented May 2 at 12:06
4

But an open-source component should be easy to run and demo.

The unspoken caveat here is that a component does not necessarily carry the responsibility of providing the entire stack in and of itself. This is the software equivalent of "batteries not included".

Yeah, it would be great customer experience if you could provide some batteries so they can use your device immediately, but this becomes less justifiable as the complexity of your "battery" increases. There might even be cases where it's not meaningfully possible, e.g. if your tool is an improvement that's supposed to go on top of another tool. The aftermarket floormats I bought don't need to come with a demo car, so to speak.

Using a .dist file here is usually a good compromise between the two. It provides an easy default config file, while not actually being in place (due to the added .dist file extension). This requires minimal user interaction, i.e. copying the file and renaming it from .env.dist to .env. At the same time, your gitignore can be configured to ignore .env itself, so an "undisted" file doesn't sneak its way back into the repository.

This dist file could contain usable demo config values, or it could just contain documentation comments on what kind of information the user needs to source in order to get your tool up and running (e.g. an API key for an external service). Whether or not you're able to provide workable default values is very contextual and not universally answerable.

5
  • The aftermarket floormats I bought don't need to come with a demo car, so to speak. this is a bad analogy, I think, but the rest of the answer sounds reasonable. I am taken aback by the pushback from people in this thread that software shouldn't necessarily be easy to run. I disagree on that front categorically. Commented Apr 29 at 0:40
  • I'll give an example: Let's say my component is a Database Partition Tool. But it only does partitions. You point it to a database, and a Redis instance (it needs both to function in a consistent way). Well it just happens that both those services tend to run on similar ports in peoples dev environments. I want to have a file that points to those defaults; a clear description of the interface this tool needs, in one place; with a big chance he doesn't even need to edit it. Batteries included would be me including the database and the logger. Just want to be clear here. Commented Apr 29 at 0:53
  • 1
    It's not just about "easy to run", it's about reasonable configuration. Having a user delve through your application-specific settings before getting it working is bad. Asking a user to provide depended-on external components (or e.g. providing API keys to access globally accessible external components) is a different beast. It would not be unreasonable to get the user to put in the connection string to their database and redis instance. Note also that you can still additionally host a demo online, it doesn't necessarily have to be demoable from the repository code itself.
    – Flater
    Commented Apr 29 at 1:26
  • @nicholaswmin: And just to be clear, it's perfectly fine for you to reject this and hold yourself to the standard that you only ever have repositories that are immediately runnable in demo mode after checkout. But the added effort from doing so is then what you've chosen to sign up for, and more importantly this is not the overall consensus you're going to find, and you're going to have to accept that there are guidelines and blog posts out there (such as the quoted reference that seems to have spawned your question) that don't follow your personal standard. Live and let live.
    – Flater
    Commented Apr 29 at 1:57
  • ......Fair points Commented Apr 29 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.