So then this stuff, injected by phx.new
doesn’t belong here at all?
config :my_site, MySiteWeb.Endpoint,
# ...
render_errors: [view: MySiteWeb.ErrorView, accepts: ~w(html json)],
pubsub: [name: MySite.PubSub, adapter: Phoenix.PubSub.PG2]
How exactly is it easier to find the default value in a config script? I need to first know that the value is provided by config scripts (since in fact many values are not defined in config scripts), and I also need to know its name. So it looks like I still need to consult the code first, possibly also read a library documentation, before I can find the value.
How do I determine such values? The examples you’ve mentioned are the things which IME change maybe once or twice in a period of few years.
I’ve just checked the git log of one of our project’s config folder. In the past year we had some changes there. Most of them were additions of new properties, some of them were deletions, and I was able to find only one case where some value has actually been changed. And that change was due to a Phoenix upgrade, not due to “reconfiguration”. Our config scripts were more frequently modified due to making comments, than due to changing a value of some “configuration”.
We actually had more frequent changes of values typically provided in the regular code (e.g. Supervisor parameters, GenServer timeouts) than “config” values.
Perhaps we completely failed in organizing our configuration?
I’m confused here. The examples you mentioned don’t end up in app env (Erlang cookie is a VM arg, not provided by a config script), or don’t need to be in app env (secret key base).
I’m not much wiser The only clear rules I can make so far are:
- Use config script if required by library
- Use config script if values change between different mix env
The first reason can’t be avoided (although opening up an issue with the library might help).
The second reason deserves to be questioned. Given that Elixir has other means of making a decision based on mix env, why are config scripts the best approach?