X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fconfig%2Floader.ex;h=0f3ecf1ede46fc07d0cbc589411439d942763187;hb=7b0c8f0fde495e50c5434575c452addeace39e60;hp=68b247381d9680c00e876c83d07bc63a66263923;hpb=d9cb8acd3e43f2b3502f2b08ce469483c67789f6;p=akkoma
diff --git a/lib/pleroma/config/loader.ex b/lib/pleroma/config/loader.ex
index 68b247381..0f3ecf1ed 100644
--- a/lib/pleroma/config/loader.ex
+++ b/lib/pleroma/config/loader.ex
@@ -1,10 +1,8 @@
# 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
- @paths ["config/config.exs", "config/#{Mix.env()}.exs"]
-
@reject_keys [
Pleroma.Repo,
Pleroma.Web.Endpoint,
@@ -15,32 +13,28 @@ defmodule Pleroma.Config.Loader do
]
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: @paths ++ ["config/releases.exs"],
- else: @paths
+ @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
@@ -53,7 +47,7 @@ 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 == :phoenix and key == :serve_endpoints) or group == :postgrex
end)
end
end