X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fconfig%2Floader.ex;h=2a945999ed7730a067331f7661b1b63f6f841038;hb=cc6a0762022644ea751767ed6b7673e069aca855;hp=b8787cb49ad44213e20e4d0eca7c11ed0d4e3ce6;hpb=e93cc561cd42ff4ca7f3c95cdbf8dfa7fb9f4a74;p=akkoma
diff --git a/lib/pleroma/config/loader.ex b/lib/pleroma/config/loader.ex
index b8787cb49..2a945999e 100644
--- a/lib/pleroma/config/loader.ex
+++ b/lib/pleroma/config/loader.ex
@@ -1,44 +1,47 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Config.Loader do
+ # These modules are only being used as keys here (for equality check),
+ # so it's okay to use `Module.concat/1` to have the compiler ignore them.
@reject_keys [
- Pleroma.Repo,
- Pleroma.Web.Endpoint,
+ Module.concat(["Pleroma.Repo"]),
+ Module.concat(["Pleroma.Web.Endpoint"]),
:env,
:configurable_from_database,
:database,
:swarm
]
+ @reject_groups [
+ :postgrex,
+ :tesla
+ ]
+
if Code.ensure_loaded?(Config.Reader) do
- @spec load(Path.t()) :: keyword()
- def load(path), do: Config.Reader.read!(path)
+ @reader Config.Reader
- defp do_merge(conf1, conf2), do: Config.Reader.merge(conf1, conf2)
+ def read(path), do: @reader.read!(path)
else
# support for Elixir less than 1.9
- @spec load(Path.t()) :: keyword()
- def load(path) do
+ @reader Mix.Config
+ def read(path) do
path
- |> Mix.Config.eval!()
+ |> @reader.eval!()
|> elem(0)
end
-
- defp do_merge(conf1, conf2), do: Mix.Config.merge(conf1, conf2)
end
- @spec load_and_merge() :: keyword()
- def load_and_merge do
- all_paths =
- if Pleroma.Config.get(:release),
- do: ["config/config.exs", "config/releases.exs"],
- else: ["config/config.exs"]
+ @spec read(Path.t()) :: keyword()
+
+ @spec merge(keyword(), keyword()) :: keyword()
+ def merge(c1, c2), do: @reader.merge(c1, c2)
- all_paths
- |> Enum.map(&load(&1))
- |> Enum.reduce([], &do_merge(&2, &1))
+ @spec default_config() :: keyword()
+ def default_config do
+ "config/config.exs"
+ |> read()
|> filter()
end
@@ -51,7 +54,8 @@ defmodule Pleroma.Config.Loader do
@spec filter_group(atom(), keyword()) :: keyword()
def filter_group(group, configs) do
Enum.reject(configs[group], fn {key, _v} ->
- key in @reject_keys or (group == :phoenix and key == :serve_endpoints)
+ key in @reject_keys or group in @reject_groups or
+ (group == :phoenix and key == :serve_endpoints)
end)
end
end