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 82d6a688..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 @@ -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,19 @@ 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 -> + 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 end