X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fconfig%2Floader.ex;h=64e7de6df1a77189323bd1bfac321ffe2bd912bc;hb=6107440ea0da3a9e59576a86a9dab50acd83936e;hp=b8787cb49ad44213e20e4d0eca7c11ed0d4e3ce6;hpb=3eddd9caa61a2ac431eb57cd4c835db608702a7d;p=akkoma
diff --git a/lib/pleroma/config/loader.ex b/lib/pleroma/config/loader.ex
index b8787cb49..64e7de6df 100644
--- a/lib/pleroma/config/loader.ex
+++ b/lib/pleroma/config/loader.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Config.Loader do
@@ -12,33 +12,34 @@ defmodule Pleroma.Config.Loader do
: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 +52,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