@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
with {_, true} <- {:configurable, Config.get(:configurable_from_database)} do
# We need to restart applications for loaded settings take effect
- # TODO: some problem with prometheus after restart!
- reject_restart =
- if restart_pleroma? do
- [nil, :prometheus]
- else
- [:pleroma, nil, :prometheus]
- end
-
{logger, other} =
(Repo.all(ConfigDB) ++ deleted_settings)
|> Enum.map(&transform_and_merge/1)
started_applications = Application.started_applications()
+ # TODO: some problem with prometheus after restart!
+ reject = [nil, :prometheus, :postgrex]
+
+ reject =
+ if restart_pleroma? do
+ reject
+ else
+ [:pleroma | reject]
+ end
+
other
|> Enum.map(&update/1)
|> Enum.uniq()
- |> Enum.reject(&(&1 in reject_restart))
+ |> Enum.reject(&(&1 in reject))
|> maybe_set_pleroma_last()
|> Enum.each(&restart(started_applications, &1, Config.get(:env)))
refute Application.get_env(:pleroma, :test_key)
refute Application.get_env(:idna, :test_key)
refute Application.get_env(:quack, :test_key)
+ refute Application.get_env(:postgrex, :test_key)
initial = Application.get_env(:logger, :level)
ConfigDB.create(%{
value: [:test_value1, :test_value2]
})
+ ConfigDB.create(%{
+ group: ":postgrex",
+ key: ":test_key",
+ value: :value
+ })
+
ConfigDB.create(%{group: ":logger", key: ":level", value: :debug})
TransferTask.start_link([])
assert Application.get_env(:idna, :test_key) == [live: 15, com: 35]
assert Application.get_env(:quack, :test_key) == [:test_value1, :test_value2]
assert Application.get_env(:logger, :level) == :debug
+ assert Application.get_env(:postgrex, :test_key) == :value
on_exit(fn ->
Application.delete_env(:pleroma, :test_key)
Application.delete_env(:idna, :test_key)
Application.delete_env(:quack, :test_key)
+ Application.delete_env(:postgrex, :test_key)
Application.put_env(:logger, :level, initial)
end)
end
config :quack, level: :info
config :pleroma, Pleroma.Repo, pool: Ecto.Adapters.SQL.Sandbox
+
+config :postgrex, :json_library, Poison
on_exit(fn -> Application.put_env(:quack, :level, initial) end)
end
- test "settings are migrated to db" do
+ test "filtered settings are migrated to db" do
assert Repo.all(ConfigDB) == []
Mix.Tasks.Pleroma.Config.migrate_to_db("test/fixtures/config/temp.secret.exs")
config2 = ConfigDB.get_by_params(%{group: ":pleroma", key: ":second_setting"})
config3 = ConfigDB.get_by_params(%{group: ":quack", key: ":level"})
refute ConfigDB.get_by_params(%{group: ":pleroma", key: "Pleroma.Repo"})
+ refute ConfigDB.get_by_params(%{group: ":postgrex", key: ":json_library"})
assert ConfigDB.from_binary(config1.value) == [key: "value", key2: [Repo]]
assert ConfigDB.from_binary(config2.value) == [key: "value2", key2: ["Activity"]]