diff options
| author | Michael Klishin <mklishin@pivotal.io> | 2019-11-12 04:12:55 +0300 |
|---|---|---|
| committer | Michael Klishin <mklishin@pivotal.io> | 2019-11-12 04:12:55 +0300 |
| commit | 723e032d25cc2e2d5ef16cd53279b386b3035760 (patch) | |
| tree | 6d3731a9da5967ffa5c733b7d17192ecd334e0e2 | |
| parent | 2aa2f78104aa129b49595c2dd07b4e7e6a7b53cc (diff) | |
| download | rabbitmq-server-git-723e032d25cc2e2d5ef16cd53279b386b3035760.tar.gz | |
Support pluginless definition import in config schema
management.load_definitions is still there but being superseded
with just
load_definitions = /path/to/definitions/file.json
Part of rabbitmq/rabbitmq-management#749.
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | priv/schema/rabbit.schema | 15 | ||||
| -rw-r--r-- | src/rabbit_definitions.erl | 5 | ||||
| -rw-r--r-- | test/config_schema_SUITE_data/rabbit.snippets | 9 | ||||
| -rw-r--r-- | test/definition_import_SUITE.erl | 2 |
5 files changed, 30 insertions, 3 deletions
@@ -109,6 +109,8 @@ define PROJECT_ENV %% used by rabbit_peer_discovery_classic_config {cluster_nodes, {[], disc}}, + %% matches original default in rabbitmq-management. + %% See rabbitmq/rabbitmq-management#749 {load_definitions, none}, {config_entry_decoder, [{passphrase, undefined}]}, diff --git a/priv/schema/rabbit.schema b/priv/schema/rabbit.schema index 8db2ebf3ff..9d33ea597d 100644 --- a/priv/schema/rabbit.schema +++ b/priv/schema/rabbit.schema @@ -73,7 +73,7 @@ end}. ]}. -%% Maximum time for AMQP 0-8/0-9/0-9-1 handshake (after socket connection +%% Maximum time for 0-9-1 handshake (after socket connection %% and SSL handshake), in milliseconds. %% %% {handshake_timeout, 10000}, @@ -98,6 +98,19 @@ end}. ]}. %% +%% Definition import +%% + +%% Load definitions from a JSON file or directory of files. See +%% https://www.rabbitmq.com/management.html#load-definitions +%% +%% {load_definitions, "/path/to/schema.json"}, +%% {load_definitions, "/path/to/schemas"}, +{mapping, "load_definitions", "rabbit.load_definitions", + [{datatype, string}, + {validators, ["file_accessible"]}]}. + +%% %% Security / AAA %% ============== %% diff --git a/src/rabbit_definitions.erl b/src/rabbit_definitions.erl index 7961f6c3c6..10db0eabe2 100644 --- a/src/rabbit_definitions.erl +++ b/src/rabbit_definitions.erl @@ -22,7 +22,10 @@ -export([decode/1, decode/2, args/1]). maybe_load_definitions() -> - case application:get_env(rabbit, load_definitions) of + %% this feature was a part of rabbitmq-management for a long time, + %% so we check rabbit_management.load_definitions for backward compatibility. + Fallback = application:get_env(rabbitmq_management, load_definitions), + case application:get_env(rabbit, load_definitions, Fallback) of undefined -> ok; {ok, none} -> ok; {ok, FileOrDir} -> diff --git a/test/config_schema_SUITE_data/rabbit.snippets b/test/config_schema_SUITE_data/rabbit.snippets index fc0c2b7000..1d8ceb3db6 100644 --- a/test/config_schema_SUITE_data/rabbit.snippets +++ b/test/config_schema_SUITE_data/rabbit.snippets @@ -641,6 +641,15 @@ credential_validator.regexp = ^abc\\d+", []}, %% + %% Definitions + %% + + {definition_files, "load_definitions = test/definition_import_SUITE_data/case1.json", + [{rabbit, + [{load_definitions, "test/definition_import_SUITE_data/case1.json"}]}], + []}, + + %% %% Raft %% diff --git a/test/definition_import_SUITE.erl b/test/definition_import_SUITE.erl index dbbdcee8df..2f70832bae 100644 --- a/test/definition_import_SUITE.erl +++ b/test/definition_import_SUITE.erl @@ -8,7 +8,7 @@ %% License for the specific language governing rights and limitations %% under the License. %% -%% Copyright (c) 2016 Pivotal Software, Inc. All rights reserved. +%% Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved. %% %% This test suite covers the definitions import function |
