Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.

Commit 3a83697

Browse files
Merge pull request #445 from rabbitmq/rabbitmq-cli-443
Deprecate RABBITMQ_ERLANG_COOKIE env variable support
2 parents 6ceae81 + 898c57c commit 3a83697

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lib/rabbitmq/cli/core/ansi.ex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,20 @@ defmodule RabbitMQ.CLI.Core.ANSI do
1717
def bright(string) do
1818
"#{IO.ANSI.bright()}#{string}#{IO.ANSI.reset()}"
1919
end
20+
21+
def red(string) do
22+
"#{IO.ANSI.red()}#{string}#{IO.ANSI.reset()}"
23+
end
24+
25+
def yellow(string) do
26+
"#{IO.ANSI.yellow()}#{string}#{IO.ANSI.reset()}"
27+
end
28+
29+
def bright_red(string) do
30+
"#{IO.ANSI.bright()}#{IO.ANSI.red()}#{string}#{IO.ANSI.reset()}"
31+
end
32+
33+
def bright_yellow(string) do
34+
"#{IO.ANSI.bright()}#{IO.ANSI.yellow()}#{string}#{IO.ANSI.reset()}"
35+
end
2036
end

lib/rabbitmq/cli/core/distribution.ex

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
## Copyright (c) 2016-2020 VMware, Inc. or its affiliates. All rights reserved.
1515

1616
defmodule RabbitMQ.CLI.Core.Distribution do
17-
alias RabbitMQ.CLI.Core.{Config, Helpers}
17+
alias RabbitMQ.CLI.Core.{ANSI, Config, Helpers}
1818

1919
#
2020
# API
@@ -77,6 +77,7 @@ defmodule RabbitMQ.CLI.Core.Distribution do
7777

7878
cookie ->
7979
Node.set_cookie(cookie)
80+
maybe_warn_about_deprecated_rabbitmq_erlang_cookie_env_variable(options)
8081
:ok
8182
end
8283
end
@@ -109,4 +110,19 @@ defmodule RabbitMQ.CLI.Core.Distribution do
109110
rmq_hostname -> String.to_atom("rabbitmqcli-#{:os.getpid()}-#{rmq_hostname}")
110111
end
111112
end
113+
114+
defp maybe_warn_about_deprecated_rabbitmq_erlang_cookie_env_variable(options) do
115+
case System.get_env("RABBITMQ_ERLANG_COOKIE") do
116+
nil -> :ok
117+
_ ->
118+
case Config.output_less?(options) do
119+
true -> :ok
120+
false ->
121+
warning = ANSI.bright_red("RABBITMQ_ERLANG_COOKIE env variable support is deprecated and will be REMOVED in a future version. ") <>
122+
ANSI.yellow("Use the $HOME/.erlang.cookie file or the --erlang-cookie switch instead.")
123+
124+
IO.puts(warning)
125+
end
126+
end
127+
end
112128
end

0 commit comments

Comments
 (0)