1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Config.Loader do
10 :configurable_from_database,
15 if Code.ensure_loaded?(Config.Reader) do
16 @spec load(Path.t()) :: keyword()
17 def load(path), do: Config.Reader.read!(path)
19 defp do_merge(conf1, conf2), do: Config.Reader.merge(conf1, conf2)
21 # support for Elixir less than 1.9
22 @spec load(Path.t()) :: keyword()
29 defp do_merge(conf1, conf2), do: Mix.Config.merge(conf1, conf2)
32 @spec load_and_merge() :: keyword()
35 if Pleroma.Config.get(:release),
36 do: ["config/config.exs", "config/releases.exs"],
37 else: ["config/config.exs"]
40 |> Enum.map(&load(&1))
41 |> Enum.reduce([], &do_merge(&2, &1))
45 defp filter(configs) do
48 |> Enum.reduce([], &Keyword.put(&2, &1, filter_group(&1, configs)))
51 @spec filter_group(atom(), keyword()) :: keyword()
52 def filter_group(group, configs) do
53 Enum.reject(configs[group], fn {key, _v} ->
54 key in @reject_keys or (group == :phoenix and key == :serve_endpoints)