Remove a clause that would never match

This commit is contained in:
Michael Klishin 2021-02-22 17:12:44 +03:00
parent 2273797d36
commit 0d615080f2
No known key found for this signature in database
GPG Key ID: E80EDCFA0CDB21EE
1 changed files with 18 additions and 23 deletions

View File

@ -60,27 +60,22 @@
{translation,
"rabbitmq_auth_backend_oauth2.key_config.signing_keys",
fun(Conf) ->
case cuttlefish:conf_get("auth_oauth2.signing_keys", Conf, undefined) of
none ->
#{};
_ ->
Settings = cuttlefish_variable:filter_by_prefix("auth_oauth2.signing_keys", Conf),
ReadFileFun =
fun(Path) ->
case file:read_file(Path) of
{ok, Bin} ->
string:trim(Bin, trailing, "\n");
_ ->
% cuttlefish validators are not invoked for properties with $variables?
cuttlefish:invalid("file does not exist or cannot be read by the node")
end
end,
SigningKeys =
lists:map(fun(Key) ->
{Id, Path} = Key,
{list_to_binary(lists:last(Id)), ReadFileFun(Path)}
end,
Settings),
maps:from_list(SigningKeys)
end
Settings = cuttlefish_variable:filter_by_prefix("auth_oauth2.signing_keys", Conf),
TryReadingFileFun =
fun(Path) ->
case file:read_file(Path) of
{ok, Bin} ->
string:trim(Bin, trailing, "\n");
_ ->
%% this throws and makes Cuttlefish treak the key as invalid
cuttlefish:invalid("file does not exist or cannot be read by the node")
end
end,
SigningKeys =
lists:map(fun(Key) ->
{Id, Path} = Key,
{list_to_binary(lists:last(Id)), TryReadingFileFun(Path)}
end,
Settings),
maps:from_list(SigningKeys)
end}.