Skip to content

Commit c95a95f

Browse files
CLI: mix format
1 parent f62d46c commit c95a95f

19 files changed

+133
-81
lines changed

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/cluster_status_command.ex

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClusterStatusCommand do
5252
status0 ->
5353
tags = cluster_tags(node_name, timeout)
5454
status = status0 ++ [{:cluster_tags, tags}]
55+
5556
case :rabbit_misc.rpc_call(node_name, :rabbit_nodes, :list_running, []) do
5657
{:badrpc, _} = err ->
5758
err
@@ -136,10 +137,10 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClusterStatusCommand do
136137
[
137138
"\n#{bright("Cluster Tags")}\n"
138139
] ++
139-
case m[:cluster_tags] do
140-
[] -> ["(none)"]
141-
tags -> cluster_tag_lines(tags)
142-
end
140+
case m[:cluster_tags] do
141+
[] -> ["(none)"]
142+
tags -> cluster_tag_lines(tags)
143+
end
143144

144145
disk_nodes_section =
145146
[
@@ -397,11 +398,12 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClusterStatusCommand do
397398

398399
defp cluster_tags(node, timeout) do
399400
case :rabbit_misc.rpc_call(
400-
node,
401-
:rabbit_runtime_parameters,
402-
:value_global,
403-
[:cluster_tags],
404-
timeout) do
401+
node,
402+
:rabbit_runtime_parameters,
403+
:value_global,
404+
[:cluster_tags],
405+
timeout
406+
) do
405407
:not_found -> []
406408
tags -> tags
407409
end

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/decode_command.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DecodeCommand do
8787
catch
8888
_, _ ->
8989
IO.inspect(__STACKTRACE__)
90+
9091
{:error,
9192
"Failed to decrypt the value. Things to check: is the passphrase correct? Are the cipher and hash algorithms the same as those used for encryption?"}
9293
end
@@ -111,6 +112,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DecodeCommand do
111112
catch
112113
_, _ ->
113114
IO.inspect(__STACKTRACE__)
115+
114116
{:error,
115117
"Failed to decrypt the value. Things to check: is the passphrase correct? Are the cipher and hash algorithms the same as those used for encryption?"}
116118
end

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/decrypt_conf_value_command.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DecryptConfValueCommand do
9191
catch
9292
_, _ ->
9393
IO.inspect(__STACKTRACE__)
94+
9495
{:error,
9596
"Failed to decrypt the value. Things to check: is the passphrase correct? Are the cipher and hash algorithms the same as those used for encryption?"}
9697
end
@@ -118,6 +119,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DecryptConfValueCommand do
118119
catch
119120
_, _ ->
120121
IO.inspect(__STACKTRACE__)
122+
121123
{:error,
122124
"Failed to decrypt the value. Things to check: is the passphrase correct? Are the cipher and hash algorithms the same as those used for encryption?"}
123125
end
@@ -130,7 +132,8 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DecryptConfValueCommand do
130132
end
131133

132134
def usage,
133-
do: "decrypt_conf_value value passphrase [--cipher <cipher>] [--hash <hash>] [--iterations <iterations>]"
135+
do:
136+
"decrypt_conf_value value passphrase [--cipher <cipher>] [--hash <hash>] [--iterations <iterations>]"
134137

135138
def usage_additional() do
136139
[
@@ -166,6 +169,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DecryptConfValueCommand do
166169

167170
{:encrypted, untagged_val}
168171
end
172+
169173
defp tag_input_value_with_encrypted(value) do
170174
{:encrypted, value}
171175
end

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/delete_vhost_command.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DeleteVhostCommand do
2020
end
2121

2222
def output({:error, :protected_from_deletion}, %{formatter: "json", node: node_name}) do
23-
{:error, %{"result" => "error", "node" => node_name, "reason" => @protected_from_deletion_err}}
23+
{:error,
24+
%{"result" => "error", "node" => node_name, "reason" => @protected_from_deletion_err}}
2425
end
26+
2527
def output({:error, :protected_from_deletion}, _opts) do
2628
{:error, ExitCodes.exit_dataerr(), @protected_from_deletion_err}
2729
end
30+
2831
use RabbitMQ.CLI.DefaultOutput
2932

3033
def usage, do: "delete_vhost <vhost>"

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/enable_feature_flag_command.ex

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,25 @@ defmodule RabbitMQ.CLI.Ctl.Commands.EnableFeatureFlagCommand do
1010
def switches(), do: [experimental: :boolean, opt_in: :boolean]
1111
def aliases(), do: [e: :experimental, o: :opt_in]
1212

13-
def merge_defaults(args, opts), do: { args, Map.merge(%{experimental: false, opt_in: false}, opts) }
13+
def merge_defaults(args, opts),
14+
do: {args, Map.merge(%{experimental: false, opt_in: false}, opts)}
1415

1516
def validate([], _opts), do: {:validation_failure, :not_enough_args}
16-
def validate([_ | _] = args, _opts) when length(args) > 1, do: {:validation_failure, :too_many_args}
17+
18+
def validate([_ | _] = args, _opts) when length(args) > 1,
19+
do: {:validation_failure, :too_many_args}
1720

1821
def validate([""], _opts),
19-
do: {:validation_failure, {:bad_argument, "feature flag (or group) name cannot be an empty string"}}
22+
do:
23+
{:validation_failure,
24+
{:bad_argument, "feature flag (or group) name cannot be an empty string"}}
2025

2126
def validate([_], _opts), do: :ok
2227

2328
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
2429

2530
def run(["all"], %{node: node_name, opt_in: opt_in, experimental: experimental}) do
26-
has_opted_in = (opt_in || experimental)
31+
has_opted_in = opt_in || experimental
2732
enable_all(node_name, has_opted_in)
2833
end
2934

@@ -39,9 +44,8 @@ defmodule RabbitMQ.CLI.Ctl.Commands.EnableFeatureFlagCommand do
3944
enable_all(node_name, false)
4045
end
4146

42-
4347
def run([feature_flag], %{node: node_name, opt_in: opt_in, experimental: experimental}) do
44-
has_opted_in = (opt_in || experimental)
48+
has_opted_in = opt_in || experimental
4549
enable_one(node_name, feature_flag, has_opted_in)
4650
end
4751

@@ -57,10 +61,9 @@ defmodule RabbitMQ.CLI.Ctl.Commands.EnableFeatureFlagCommand do
5761
enable_one(node_name, feature_flag, false)
5862
end
5963

60-
6164
def output({:error, :unsupported}, %{node: node_name}) do
6265
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_usage(),
63-
"This feature flag is not supported by node #{node_name}"}
66+
"This feature flag is not supported by node #{node_name}"}
6467
end
6568

6669
use RabbitMQ.CLI.DefaultOutput
@@ -96,8 +99,11 @@ defmodule RabbitMQ.CLI.Ctl.Commands.EnableFeatureFlagCommand do
9699
defp enable_all(node_name, has_opted_in) do
97100
case has_opted_in do
98101
true ->
99-
msg = "`--opt-in` (aliased as `--experimental`) flag is not allowed when enabling all feature flags.\nUse --opt-in with a specific feature flag name if to enable an opt-in flag"
102+
msg =
103+
"`--opt-in` (aliased as `--experimental`) flag is not allowed when enabling all feature flags.\nUse --opt-in with a specific feature flag name if to enable an opt-in flag"
104+
100105
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_usage(), msg}
106+
101107
_ ->
102108
case :rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :enable_all, []) do
103109
{:badrpc, _} = err -> err
@@ -107,20 +113,26 @@ defmodule RabbitMQ.CLI.Ctl.Commands.EnableFeatureFlagCommand do
107113
end
108114

109115
defp enable_one(node_name, feature_flag, has_opted_in) do
110-
case {has_opted_in, :rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :get_stability, [
111-
String.to_atom(feature_flag)
112-
])} do
113-
{_, {:badrpc, _} = err} -> err
114-
{false, :experimental} ->
115-
msg = "Feature flag #{feature_flag} requires the user to explicitly opt-in.\nUse --opt-in with a specific feature flag name if to enable an opt-in flag"
116-
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_usage(), msg}
117-
_ ->
118-
case :rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :enable, [
116+
case {has_opted_in,
117+
:rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :get_stability, [
119118
String.to_atom(feature_flag)
120-
]) do
121-
{:badrpc, _} = err -> err
122-
other -> other
123-
end
119+
])} do
120+
{_, {:badrpc, _} = err} ->
121+
err
122+
123+
{false, :experimental} ->
124+
msg =
125+
"Feature flag #{feature_flag} requires the user to explicitly opt-in.\nUse --opt-in with a specific feature flag name if to enable an opt-in flag"
126+
127+
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_usage(), msg}
128+
129+
_ ->
130+
case :rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :enable, [
131+
String.to_atom(feature_flag)
132+
]) do
133+
{:badrpc, _} = err -> err
134+
other -> other
135+
end
124136
end
125137
end
126138
end

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/encode_command.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ defmodule RabbitMQ.CLI.Ctl.Commands.EncodeCommand do
149149

150150
def help_section(), do: :configuration
151151

152-
def description(), do: "Encrypts a sensitive configuration value to be used in the advanced.config file"
152+
def description(),
153+
do: "Encrypts a sensitive configuration value to be used in the advanced.config file"
153154

154155
#
155156
# Implementation

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/encrypt_conf_value_command.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ defmodule RabbitMQ.CLI.Ctl.Commands.EncryptConfValueCommand do
125125
end
126126

127127
def usage,
128-
do: "encrypt_conf_value value passphrase [--cipher <cipher>] [--hash <hash>] [--iterations <iterations>]"
128+
do:
129+
"encrypt_conf_value value passphrase [--cipher <cipher>] [--hash <hash>] [--iterations <iterations>]"
129130

130131
def usage_additional() do
131132
[
@@ -145,7 +146,8 @@ defmodule RabbitMQ.CLI.Ctl.Commands.EncryptConfValueCommand do
145146

146147
def help_section(), do: :configuration
147148

148-
def description(), do: "Encrypts a sensitive configuration value to be used in the advanced.config file"
149+
def description(),
150+
do: "Encrypts a sensitive configuration value to be used in the advanced.config file"
149151

150152
#
151153
# Implementation

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/status_command.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.StatusCommand do
6969

7070
def output(result, %{node: node_name, unit: unit}) when is_list(result) do
7171
m = result_map(result)
72+
7273
product_name_section =
7374
case m do
7475
%{:product_name => product_name} when product_name != "" ->
@@ -142,14 +143,15 @@ defmodule RabbitMQ.CLI.Ctl.Commands.StatusCommand do
142143
end
143144

144145
IO.inspect(m[:tags])
146+
145147
tags_section =
146148
[
147149
"\n#{bright("Tags")}\n"
148150
] ++
149151
case m[:tags] do
150152
nil -> ["(none)"]
151-
[] -> ["(none)"]
152-
xs -> tag_lines(xs)
153+
[] -> ["(none)"]
154+
xs -> tag_lines(xs)
153155
end
154156

155157
breakdown = compute_relative_values(m[:memory])

deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_if_any_deprecated_features_are_used_command.ex

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,29 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckIfAnyDeprecatedFeaturesAreUsedC
1515
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
1616

1717
def run([], %{node: node_name, timeout: timeout}) do
18-
deprecated_features_list = :rabbit_misc.rpc_call(
19-
node_name,
20-
:rabbit_deprecated_features,
21-
:list,
22-
[:used],
23-
timeout
24-
)
18+
deprecated_features_list =
19+
:rabbit_misc.rpc_call(
20+
node_name,
21+
:rabbit_deprecated_features,
22+
:list,
23+
[:used],
24+
timeout
25+
)
2526

2627
# health checks return true if they pass
2728
case deprecated_features_list do
2829
{:badrpc, _} = err ->
2930
err
31+
3032
{:error, _} = err ->
3133
err
34+
3235
_ ->
3336
names = Enum.sort(Map.keys(deprecated_features_list))
37+
3438
case names do
3539
[] -> true
36-
_ -> {false, names}
40+
_ -> {false, names}
3741
end
3842
end
3943
end

deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/metadata_store_status_command.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.MetadataStoreStatusCommand do
1717
case :rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :is_enabled, [:khepri_db]) do
1818
true ->
1919
:rabbit_misc.rpc_call(node_name, :rabbit_khepri, :status, [])
20+
2021
false ->
21-
[[{<<"Metadata Store">>, "mnesia"}]]
22+
[[{<<"Metadata Store">>, "mnesia"}]]
2223
end
2324
end
2425

0 commit comments

Comments
 (0)