|
@@ -152,8 +152,10 @@ make_name_vsn_string(Name, Vsn) ->
|
|
|
-spec ensure_installed() -> ok.
|
|
-spec ensure_installed() -> ok.
|
|
|
ensure_installed() ->
|
|
ensure_installed() ->
|
|
|
Fun = fun(#{name_vsn := NameVsn}) ->
|
|
Fun = fun(#{name_vsn := NameVsn}) ->
|
|
|
- ensure_installed(NameVsn),
|
|
|
|
|
- []
|
|
|
|
|
|
|
+ case ensure_installed(NameVsn) of
|
|
|
|
|
+ ok -> [];
|
|
|
|
|
+ {error, Reason} -> [{NameVsn, Reason}]
|
|
|
|
|
+ end
|
|
|
end,
|
|
end,
|
|
|
ok = for_plugins(Fun).
|
|
ok = for_plugins(Fun).
|
|
|
|
|
|
|
@@ -169,8 +171,8 @@ ensure_installed(NameVsn) ->
|
|
|
case ensure_exists_and_installed(NameVsn) of
|
|
case ensure_exists_and_installed(NameVsn) of
|
|
|
ok ->
|
|
ok ->
|
|
|
maybe_post_op_after_installed(NameVsn);
|
|
maybe_post_op_after_installed(NameVsn);
|
|
|
- _ ->
|
|
|
|
|
- ok
|
|
|
|
|
|
|
+ {error, _Reason} = Err ->
|
|
|
|
|
+ Err
|
|
|
end
|
|
end
|
|
|
end.
|
|
end.
|
|
|
|
|
|
|
@@ -280,8 +282,10 @@ ensure_started(NameVsn) ->
|
|
|
-spec ensure_stopped() -> ok.
|
|
-spec ensure_stopped() -> ok.
|
|
|
ensure_stopped() ->
|
|
ensure_stopped() ->
|
|
|
Fun = fun(#{name_vsn := NameVsn, enable := true}) ->
|
|
Fun = fun(#{name_vsn := NameVsn, enable := true}) ->
|
|
|
- ensure_stopped(NameVsn),
|
|
|
|
|
- []
|
|
|
|
|
|
|
+ case ensure_stopped(NameVsn) of
|
|
|
|
|
+ ok -> [];
|
|
|
|
|
+ {error, Reason} -> [{NameVsn, Reason}]
|
|
|
|
|
+ end
|
|
|
end,
|
|
end,
|
|
|
ok = for_plugins(Fun).
|
|
ok = for_plugins(Fun).
|
|
|
|
|
|
|
@@ -314,7 +318,7 @@ get_config(NameVsn, #{format := ?CONFIG_FORMAT_AVRO}) ->
|
|
|
{ok, _AvroJson} = Res -> Res;
|
|
{ok, _AvroJson} = Res -> Res;
|
|
|
{error, _Reason} = Err -> Err
|
|
{error, _Reason} = Err -> Err
|
|
|
end;
|
|
end;
|
|
|
-get_config(NameVsn, Options = #{format := ?CONFIG_FORMAT_MAP}) ->
|
|
|
|
|
|
|
+get_config(NameVsn, #{format := ?CONFIG_FORMAT_MAP} = Options) ->
|
|
|
get_config(NameVsn, Options, #{}).
|
|
get_config(NameVsn, Options, #{}).
|
|
|
|
|
|
|
|
%% Present default config value only in map format.
|
|
%% Present default config value only in map format.
|
|
@@ -714,7 +718,7 @@ ensure_exists_and_installed(NameVsn) ->
|
|
|
case get_tar(NameVsn) of
|
|
case get_tar(NameVsn) of
|
|
|
{ok, TarContent} ->
|
|
{ok, TarContent} ->
|
|
|
ok = file:write_file(pkg_file_path(NameVsn), TarContent),
|
|
ok = file:write_file(pkg_file_path(NameVsn), TarContent),
|
|
|
- ok = do_ensure_installed(NameVsn);
|
|
|
|
|
|
|
+ do_ensure_installed(NameVsn);
|
|
|
_ ->
|
|
_ ->
|
|
|
%% If not, try to get it from the cluster.
|
|
%% If not, try to get it from the cluster.
|
|
|
do_get_from_cluster(NameVsn)
|
|
do_get_from_cluster(NameVsn)
|
|
@@ -733,13 +737,13 @@ do_get_from_cluster(NameVsn) ->
|
|
|
name_vsn => NameVsn,
|
|
name_vsn => NameVsn,
|
|
|
node_errors => NodeErrors
|
|
node_errors => NodeErrors
|
|
|
}),
|
|
}),
|
|
|
- {error, plugin_not_found};
|
|
|
|
|
|
|
+ {error, #{reason => not_found, name_vsn => NameVsn}};
|
|
|
{error, _} ->
|
|
{error, _} ->
|
|
|
?SLOG(error, #{
|
|
?SLOG(error, #{
|
|
|
msg => "no_nodes_to_copy_plugin_from",
|
|
msg => "no_nodes_to_copy_plugin_from",
|
|
|
name_vsn => NameVsn
|
|
name_vsn => NameVsn
|
|
|
}),
|
|
}),
|
|
|
- {error, plugin_not_found}
|
|
|
|
|
|
|
+ {error, #{reason => not_found, name_vsn => NameVsn}}
|
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
get_from_any_node([], _NameVsn, Errors) ->
|
|
get_from_any_node([], _NameVsn, Errors) ->
|
|
@@ -763,7 +767,7 @@ get_avro_config_from_any_node([Node | T], NameVsn, Errors) ->
|
|
|
{ok, _} = Res ->
|
|
{ok, _} = Res ->
|
|
|
Res;
|
|
Res;
|
|
|
Err ->
|
|
Err ->
|
|
|
- get_from_any_node(T, NameVsn, [{Node, Err} | Errors])
|
|
|
|
|
|
|
+ get_avro_config_from_any_node(T, NameVsn, [{Node, Err} | Errors])
|
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
plugins_readme(NameVsn, #{fill_readme := true}, Info) ->
|
|
plugins_readme(NameVsn, #{fill_readme := true}, Info) ->
|