From acb68e395e237dfcd6474416c20455661feebf88 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Thu, 2 Jul 2020 08:25:49 +0300 Subject: [PATCH 1/2] Deprecate RABBITMQ_ERLANG_COOKIE env variable support It's not worth the confusion it causes in practice since the server does not support it. Per discussion with @gerhard @dumbbell. Closes #443. --- lib/rabbitmq/cli/core/distribution.ex | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/rabbitmq/cli/core/distribution.ex b/lib/rabbitmq/cli/core/distribution.ex index 82d6a688..4f3c64ec 100644 --- a/lib/rabbitmq/cli/core/distribution.ex +++ b/lib/rabbitmq/cli/core/distribution.ex @@ -77,6 +77,7 @@ defmodule RabbitMQ.CLI.Core.Distribution do cookie -> Node.set_cookie(cookie) + maybe_warn_about_deprecated_rabbitmq_erlang_cookie_env_variable(options) :ok end end @@ -109,4 +110,17 @@ defmodule RabbitMQ.CLI.Core.Distribution do rmq_hostname -> String.to_atom("rabbitmqcli-#{:os.getpid()}-#{rmq_hostname}") end end + + defp maybe_warn_about_deprecated_rabbitmq_erlang_cookie_env_variable(options) do + case System.get_env("RABBITMQ_ERLANG_COOKIE") do + nil -> :ok + _ -> + case Config.output_less?(options) do + true -> :ok + false -> + IO.puts("RABBITMQ_ERLANG_COOKIE env variable support is deprecated and will be REMOVED in a future version. " <> + "Use the $HOME/.erlang.cookie file or the --erlang-cookie switch instead.") + end + end + end end From 898c57c2d05c27185e70f73dfbe60d17057b4f6b Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Fri, 3 Jul 2020 09:05:35 +0700 Subject: [PATCH 2/2] Make RABBITMQ_ERLANG_COOKIE deprecation message pop [as in colors] --- lib/rabbitmq/cli/core/ansi.ex | 16 ++++++++++++++++ lib/rabbitmq/cli/core/distribution.ex | 8 +++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/rabbitmq/cli/core/ansi.ex b/lib/rabbitmq/cli/core/ansi.ex index 628c3228..26f03b4c 100644 --- a/lib/rabbitmq/cli/core/ansi.ex +++ b/lib/rabbitmq/cli/core/ansi.ex @@ -17,4 +17,20 @@ defmodule RabbitMQ.CLI.Core.ANSI do def bright(string) do "#{IO.ANSI.bright()}#{string}#{IO.ANSI.reset()}" end + + def red(string) do + "#{IO.ANSI.red()}#{string}#{IO.ANSI.reset()}" + end + + def yellow(string) do + "#{IO.ANSI.yellow()}#{string}#{IO.ANSI.reset()}" + end + + def bright_red(string) do + "#{IO.ANSI.bright()}#{IO.ANSI.red()}#{string}#{IO.ANSI.reset()}" + end + + def bright_yellow(string) do + "#{IO.ANSI.bright()}#{IO.ANSI.yellow()}#{string}#{IO.ANSI.reset()}" + end end diff --git a/lib/rabbitmq/cli/core/distribution.ex b/lib/rabbitmq/cli/core/distribution.ex index 4f3c64ec..a45d3dae 100644 --- a/lib/rabbitmq/cli/core/distribution.ex +++ b/lib/rabbitmq/cli/core/distribution.ex @@ -14,7 +14,7 @@ ## Copyright (c) 2016-2020 VMware, Inc. or its affiliates. All rights reserved. defmodule RabbitMQ.CLI.Core.Distribution do - alias RabbitMQ.CLI.Core.{Config, Helpers} + alias RabbitMQ.CLI.Core.{ANSI, Config, Helpers} # # API @@ -118,8 +118,10 @@ defmodule RabbitMQ.CLI.Core.Distribution do case Config.output_less?(options) do true -> :ok false -> - IO.puts("RABBITMQ_ERLANG_COOKIE env variable support is deprecated and will be REMOVED in a future version. " <> - "Use the $HOME/.erlang.cookie file or the --erlang-cookie switch instead.") + warning = ANSI.bright_red("RABBITMQ_ERLANG_COOKIE env variable support is deprecated and will be REMOVED in a future version. ") <> + ANSI.yellow("Use the $HOME/.erlang.cookie file or the --erlang-cookie switch instead.") + + IO.puts(warning) end end end