parent
							
								
									a85908aa30
								
							
						
					
					
						commit
						5ec71c18f3
					
				|  | @ -36,24 +36,28 @@ defmodule RabbitMQ.CLI.Core.Config do | |||
|   def normalize(:longnames, _val),       do: :shortnames | ||||
|   def normalize(_, value),           do: value | ||||
| 
 | ||||
|   def get_system_option(:script_name) do | ||||
|     Path.basename(:escript.script_name()) | ||||
|     |> Path.rootname | ||||
|     |> String.to_atom | ||||
|   end | ||||
|   def get_system_option(name) do | ||||
|     system_env_option = case name do | ||||
|   def system_env_variable(name) do | ||||
|     case name do | ||||
|       :longnames            -> "RABBITMQ_USE_LONGNAME"; | ||||
|       :rabbitmq_home        -> "RABBITMQ_HOME"; | ||||
|       :mnesia_dir           -> "RABBITMQ_MNESIA_DIR"; | ||||
|       :plugins_dir          -> "RABBITMQ_PLUGINS_DIR"; | ||||
|       :plugins_expand_dir   -> "RABBITMQ_PLUGINS_EXPAND_DIR"; | ||||
|       :enabled_plugins_file -> "RABBITMQ_ENABLED_PLUGINS_FILE"; | ||||
|       :node                 -> "RABBITMQ_NODENAME"; | ||||
|       :aliases_file         -> "RABBITMQ_CLI_ALIASES_FILE"; | ||||
|       :erlang_cookie        -> "RABBITMQ_ERLANG_COOKIE"; | ||||
|       _ -> "" | ||||
|     end | ||||
|     System.get_env(system_env_option) | ||||
|   end | ||||
| 
 | ||||
|   def get_system_option(:script_name) do | ||||
|     Path.basename(:escript.script_name()) | ||||
|     |> Path.rootname | ||||
|     |> String.to_atom | ||||
|   end | ||||
|   def get_system_option(name) do | ||||
|     System.get_env(system_env_variable(name)) | ||||
|   end | ||||
| 
 | ||||
|   def default(:script_name), do: :rabbitmqctl | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ | |||
| 
 | ||||
| defmodule RabbitMQ.CLI.Plugins.Commands.DirectoriesCommand do | ||||
|   alias RabbitMQ.CLI.Plugins.Helpers, as: PluginHelpers | ||||
|   alias RabbitMQ.CLI.Core.{Helpers, Validators} | ||||
|   alias RabbitMQ.CLI.Core.{Helpers, Validators, Config} | ||||
| 
 | ||||
|   @behaviour RabbitMQ.CLI.CommandBehaviour | ||||
| 
 | ||||
|  | @ -73,9 +73,9 @@ defmodule RabbitMQ.CLI.Plugins.Commands.DirectoriesCommand do | |||
|       :rabbit_misc.rpc_call(node_name, :rabbit_plugins, key, []) | ||||
|     end | ||||
|   end | ||||
|   def run([], %{offline: true}) do | ||||
|   def run([], %{offline: true} = opts) do | ||||
|     do_run fn(key) -> | ||||
|       apply(:rabbit_plugins, key, []) | ||||
|       Config.get_option(key, opts) | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|  | @ -100,7 +100,7 @@ defmodule RabbitMQ.CLI.Plugins.Commands.DirectoriesCommand do | |||
| 
 | ||||
|   defp do_run(fun) do | ||||
|     # return an error or an {:ok, map} tuple | ||||
|     Enum.reduce([:plugins_dist_dir, :plugins_expand_dir, :enabled_plugins_file], {:ok, %{}}, | ||||
|     Enum.reduce([:plugins_dir, :plugins_expand_dir, :enabled_plugins_file], {:ok, %{}}, | ||||
|                 fn _,   {:error, err} -> {:error, err} | ||||
|                    key, {:ok, acc}    -> | ||||
|                     case fun.(key) do | ||||
|  |  | |||
|  | @ -123,8 +123,10 @@ defmodule DirectoriesCommandTest do | |||
| 
 | ||||
|   test "run: when --online is used, lists plugin directories", context do | ||||
|     opts = Map.merge(context[:opts], %{online: true}) | ||||
|     assert @command.run([], opts) == {:ok, %{plugins_dist_dir: to_string(Map.get(opts, :plugins_dir)), | ||||
|                                              plugins_expand_dir: to_string(Map.get(opts, :plugins_expand_dir)), | ||||
|                                              enabled_plugins_file: to_string(Map.get(opts, :plugins_file))}} | ||||
|     dirs = %{plugins_dir: to_string(Map.get(opts, :plugins_dir)), | ||||
|              plugins_expand_dir: to_string(Map.get(opts, :plugins_expand_dir)), | ||||
|              enabled_plugins_file: to_string(Map.get(opts, :plugins_file))} | ||||
| 
 | ||||
|     assert @command.run([], opts) == {:ok, dirs} | ||||
|   end | ||||
| end | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue