Thanks for the quick response. I also tried it with File.exists?, but the pipeline seemed a little distracting.
# Import secrets across all environments if "config.secret.exs" |> Path.expand(__DIR__) |> File.exists?() do import_config "config.secret.exs" end # Import env specific settings if "#{Mix.env()}.secret.exs" |> Path.expand(__DIR__) |> File.exists?() do import_config "#{Mix.env()}.secret.exs" end I'm happy to wait for the configuration restart discussion or after Elixir 1.9. Thanks again for your feedback! Aaron Renner On Wednesday, February 20, 2019 at 4:03:08 PM UTC-7, José Valim wrote: > > A import_config_if_available has been proposed in the past (I believe by > me) but rejected because you can do a "FIle.exists?" check before. > > We are planning to slightly rework the configuration system for Elixir > v1.9 due to releases so it may be that it makes the cut but for now I would > wait until the discussion about configuration restart (I am siting on one > or two drafts) or bring it up for rediscussion once v1.9 is out. > > > *José Valim* > www.plataformatec.com.br > Skype: jv.ptec > Founder and Director of R&D > > > On Wed, Feb 20, 2019 at 11:55 PM Aaron Renner <aaron....@gmail.com > <javascript:>> wrote: > >> Hi, >> >> I'm curious what you'd think of having a variant of >> Mix.Config.import_config/1 that doesn't raise an error when the config file >> is missing. I'd like to be able to import optional configs, like >> config/prod.secret.exs if it exists, but not error if it's missing. Right >> now, I write my config/config.exs like this >> >> # config/config.exs >> >> use Mix.Config >> >> config :my_app, setting: true >> >> #Import env specific config >> import_config "#{Mix.env()}.exs" >> >> # Import secrets across all environments >> try do >> import_config "config.secret.exs" >> rescue >> Code.LoadError -> :ok >> end >> >> # Import env specific settings >> try do >> import_config "#{Mix.env()}.secret.exs" >> rescue >> Code.LoadError -> :ok >> end >> >> >> If you include a wildcard in the path to import_config/1 it doesn't raise >> an error if no files are found. What would you think about adding an >> additional argument to import_config that allows me to flag the import as >> optional? Then I could write my config like this. >> >> >> # config/config.exs >> >> use Mix.Config >> >> config :my_app, setting: true >> >> #Import env specific config >> import_config "#{Mix.env()}.exs" >> >> # Import secrets across all environments >> import_config "config.secret.exs", optional: true >> >> # Import env specific settings >> import_config "#{Mix.env()}.secret.exs", optional: true >> >> >> Any suggestions or different approaches I should try would be greatly >> appreciated! >> >> Thanks, >> Aaron Renner >> >> -- >> You received this message because you are subscribed to the Google Groups >> "elixir-lang-core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to elixir-lang-co...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/dca1f2df-aaf8-4967-b52b-d790fdad327b%40googlegroups.com >> >> <https://groups.google.com/d/msgid/elixir-lang-core/dca1f2df-aaf8-4967-b52b-d790fdad327b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/09d4c59b-a8f3-4fe8-a299-60b546fe1e36%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.