Skip to content

Commit

Permalink
Remove a Shovel JSON formatting function that's no longer necessary
Browse files Browse the repository at this point in the history
It's been eight years since 28060d5

(cherry picked from commit d3ea758)
  • Loading branch information
michaelklishin authored and mergify[bot] committed Aug 18, 2024
1 parent 4d59248 commit 5620dd9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 26 deletions.
3 changes: 1 addition & 2 deletions deps/rabbitmq_management/src/rabbit_mgmt_wm_definitions.erl
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ vhost_definitions(ReqData, VHost, Context) ->
export_binding(B, QNames)],
{ok, Vsn} = application:get_key(rabbit, vsn),
Parameters = [strip_vhost(
rabbit_mgmt_format:parameter(
rabbit_mgmt_wm_parameters:fix_shovel_publish_properties(P)))
rabbit_mgmt_format:parameter(P))
|| P <- rabbit_runtime_parameters:list(VHost)],
rabbit_mgmt_util:reply(
[{rabbit_version, rabbit_data_coercion:to_binary(Vsn)}] ++
Expand Down
3 changes: 1 addition & 2 deletions deps/rabbitmq_management/src/rabbit_mgmt_wm_parameter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ resource_exists(ReqData, Context) ->
end, ReqData, Context}.

to_json(ReqData, Context) ->
rabbit_mgmt_util:reply(rabbit_mgmt_format:parameter(
rabbit_mgmt_wm_parameters:fix_shovel_publish_properties(parameter(ReqData))),
rabbit_mgmt_util:reply(rabbit_mgmt_format:parameter(parameter(ReqData)),
ReqData, Context).

accept_content(ReqData0, Context = #context{user = User}) ->
Expand Down
21 changes: 1 addition & 20 deletions deps/rabbitmq_management/src/rabbit_mgmt_wm_parameters.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

-export([init/2, to_json/2, content_types_provided/2, is_authorized/2,
resource_exists/2, basic/1]).
-export([fix_shovel_publish_properties/1]).
-export([variances/2]).

-include_lib("rabbitmq_management_agent/include/rabbit_mgmt_records.hrl").
Expand Down Expand Up @@ -40,24 +39,6 @@ is_authorized(ReqData, Context) ->

%%--------------------------------------------------------------------

%% Hackish fix to make sure we return a JSON object instead of an empty list
%% when the publish-properties value is empty.
fix_shovel_publish_properties(P) ->
case lists:keyfind(component, 1, P) of
{_, <<"shovel">>} ->
case lists:keytake(value, 1, P) of
{value, {_, Values}, P2} ->
case lists:keytake(<<"publish-properties">>, 1, Values) of
{_, {_, []}, Values2} ->
P2 ++ [{value, Values2 ++ [{<<"publish-properties">>, empty_struct}]}];
_ ->
P
end;
_ -> P
end;
_ -> P
end.

basic(ReqData) ->
Raw = case rabbit_mgmt_util:id(component, ReqData) of
none -> rabbit_runtime_parameters:list();
Expand All @@ -71,5 +52,5 @@ basic(ReqData) ->
end,
case Raw of
not_found -> not_found;
_ -> [rabbit_mgmt_format:parameter(fix_shovel_publish_properties(P)) || P <- Raw]
_ -> [rabbit_mgmt_format:parameter(P) || P <- Raw]
end.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ resource_exists(ReqData, Context) ->

to_json(ReqData, Context) ->
Shovel = parameter(ReqData),
rabbit_mgmt_util:reply(rabbit_mgmt_format:parameter(
rabbit_mgmt_wm_parameters:fix_shovel_publish_properties(Shovel)),
rabbit_mgmt_util:reply(rabbit_mgmt_format:parameter(Shovel),
ReqData, Context).

is_authorized(ReqData, Context) ->
Expand Down

0 comments on commit 5620dd9

Please sign in to comment.