diff options
| author | Nathan Perry <np@nathanperry.dev> | 2020-01-28 20:20:27 -0500 |
|---|---|---|
| committer | Nathan Perry <np@nathanperry.dev> | 2020-01-28 20:20:27 -0500 |
| commit | 425c63a31e424b9abe4c0f99c009c32b75e2fbc8 (patch) | |
| tree | 72e53f8775fa774d8250c6bcdec27428bd07f9bb | |
| parent | 33caa2ba29b771a1cc05e15a5f3fe0f4cfc2cdf5 (diff) | |
delete config provider
| -rw-r--r-- | apps/thulani_bot/lib/thulani/bot/env_config_provider.ex | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/apps/thulani_bot/lib/thulani/bot/env_config_provider.ex b/apps/thulani_bot/lib/thulani/bot/env_config_provider.ex deleted file mode 100644 index c8815e0..0000000 --- a/apps/thulani_bot/lib/thulani/bot/env_config_provider.ex +++ /dev/null @@ -1,61 +0,0 @@ -defmodule Thulani.Bot.EnvConfigProvider do - @behaviour Config.Provider - - @env_vars %{ - database_url: nil, - spreadsheet_id: nil, - sheets_api_key: nil, - steam_api_key: nil, - max_sheet_column: "zz", - default_hist: "5", - max_hist: "30" - } - - def init(prefix) do - "#{String.upcase(prefix)}_" - end - - def load(config, prefix) do - logger_config = - if System.get_env("#{prefix}DEBUG") do - %{ - logger: [level: :debug] - } - else - %{} - end - - result = - %{ - nostrum: [ - token: System.fetch_env!("#{prefix}TOKEN"), - shards: System.get_env("#{prefix}DISCORD_SHARDS", "1") |> Integer.parse() - ], - thulani_bot: thulani_env(prefix) - } - |> Map.merge(logger_config) - - IO.inspect(Config.Reader.merge(config, result)) - end - - defp thulani_env(prefix) do - @env_vars - |> Enum.map(fn {env_var, default} -> - canonical_env_var = - env_var - |> to_string - |> String.upcase() - |> (fn x -> prefix <> x end).() - - value = - canonical_env_var - |> System.get_env(default) - - if value == nil do - raise "required environment variable not found: #{canonical_env_var}" - end - - {env_var, value} - end) - end -end |
