Skip to content

Commit

Permalink
Introduce a new CLI tool (scope), rabbitmq-tanzu
Browse files Browse the repository at this point in the history
For Tanzu (commercial) plugins to attach their commands to instead of
polluting rabbitmqctl.

Pair: @pjk25
(cherry picked from commit 6e0f243)
  • Loading branch information
michaelklishin authored and mergify-bot committed Nov 30, 2021
1 parent 051e504 commit f7d32d6
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 35 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ SCRIPTS = rabbitmq-defaults \
rabbitmq-diagnostics \
rabbitmq-queues \
rabbitmq-upgrade \
rabbitmq-streams
rabbitmq-streams \
rabbitmq-tanzu

AUTOCOMPLETE_SCRIPTS = bash_autocomplete.sh zsh_autocomplete.sh

Expand All @@ -433,6 +434,7 @@ WINDOWS_SCRIPTS = rabbitmq-defaults.bat \
rabbitmq-service.bat \
rabbitmq-upgrade.bat \
rabbitmq-streams.bat \
rabbitmq-tanzu.bat \
rabbitmqctl.bat

UNIX_TO_DOS ?= todos
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/docs/rabbitmq-diagnostics.8
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" vim:ft=nroff:
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at https://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
.\" Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
.\"
.Dd June 19, 2021
.Dt RABBITMQ-DIAGNOSTICS 8
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/docs/rabbitmq-echopid.8
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" vim:ft=nroff:
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at https://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
.\" Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
.\"
.Dd September 28, 2019
.Dt RABBITMQ-ECHOPID.BAT 8
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/docs/rabbitmq-env.conf.5
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" vim:ft=nroff:
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at https://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
.\" Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
.\"
.Dd September 28, 2019
.Dt RABBITMQ-ENV.CONF 5
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/docs/rabbitmq-plugins.8
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" vim:ft=nroff:
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at https://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
.\" Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
.\"
.Dd September 28, 2019
.Dt RABBITMQ-PLUGINS 8
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/docs/rabbitmq-queues.8
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" vim:ft=nroff:
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at https://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
.\" Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
.\"
.Dd June 19, 2021
.Dt RABBITMQ-QUEUES 8
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/docs/rabbitmq-server.8
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" vim:ft=nroff:
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at https://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
.\" Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
.\"
.Dd September 28, 2019
.Dt RABBITMQ-SERVER 8
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/docs/rabbitmq-service.8
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" vim:ft=nroff:
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at https://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
.\" Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
.\"
.Dd September 28, 2019
.Dt RABBITMQ-SERVICE.BAT 8
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/docs/rabbitmq-upgrade.8
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" vim:ft=nroff:
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at https://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
.\" Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
.\"
.Dd June 19, 2021
.Dt RABBITMQ-UPGRADE 8
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/docs/rabbitmqctl.8
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" vim:ft=nroff:
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at https://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
.\" Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
.\"
.Dd June 19, 2021
.Dt RABBITMQCTL 8
Expand Down
23 changes: 23 additions & 0 deletions deps/rabbit/scripts/rabbitmq-tanzu
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
## This Source Code Form is subject to the terms of the Mozilla Public
## License, v. 2.0. If a copy of the MPL was not distributed with this
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
##
## Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
##

# Exit immediately if a pipeline, which may consist of a single simple command,
# a list, or a compound command returns a non-zero status
set -e

# Each variable or function that is created or modified is given the export
# attribute and marked for export to the environment of subsequent commands.
set -a

# shellcheck source=/dev/null
#
# TODO: when shellcheck adds support for relative paths, change to
# shellcheck source=./rabbitmq-env
. "${0%/*}"/rabbitmq-env

run_escript rabbitmqctl_escript "${ESCRIPT_DIR:?must be defined}"/rabbitmq-tanzu "$@"
56 changes: 56 additions & 0 deletions deps/rabbit/scripts/rabbitmq-tanzu.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@echo off
REM This Source Code Form is subject to the terms of the Mozilla Public
REM License, v. 2.0. If a copy of the MPL was not distributed with this
REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
REM
REM Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
REM

REM Scopes the variables to the current batch file
setlocal

rem Preserve values that might contain exclamation marks before
rem enabling delayed expansion
set TDP0=%~dp0
set STAR=%*
setlocal enabledelayedexpansion

REM Get default settings with user overrides for (RABBITMQ_)<var_name>
REM Non-empty defaults should be set in rabbitmq-env
call "%TDP0%\rabbitmq-env.bat" %~n0

if not exist "!ERLANG_HOME!\bin\erl.exe" (
echo.
echo ******************************
echo ERLANG_HOME not set correctly.
echo ******************************
echo.
echo Please either set ERLANG_HOME to point to your Erlang installation or place the
echo RabbitMQ server distribution in the Erlang lib folder.
echo.
exit /B 1
)

REM Disable erl_crash.dump by default for control scripts.
if not defined ERL_CRASH_DUMP_SECONDS (
set ERL_CRASH_DUMP_SECONDS=0
)

"!ERLANG_HOME!\bin\erl.exe" +B ^
-boot !CLEAN_BOOT_FILE! ^
-noinput -noshell -hidden -smp enable ^
!RABBITMQ_CTL_ERL_ARGS! ^
-kernel inet_dist_listen_min !RABBITMQ_CTL_DIST_PORT_MIN! ^
-kernel inet_dist_listen_max !RABBITMQ_CTL_DIST_PORT_MAX! ^
-run escript start ^
-escript main rabbitmqctl_escript ^
-extra "%RABBITMQ_HOME%\escript\rabbitmq-tanzu" !STAR!

if ERRORLEVEL 1 (
exit /B %ERRORLEVEL%
)

EXIT /B 0

endlocal
endlocal
6 changes: 4 additions & 2 deletions deps/rabbitmq_cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ LINKED_ESCRIPTS = escript/rabbitmq-plugins \
escript/rabbitmq-diagnostics \
escript/rabbitmq-queues \
escript/rabbitmq-streams \
escript/rabbitmq-upgrade
escript/rabbitmq-tanzu \
escript/rabbitmq-upgrade
ESCRIPTS = $(ACTUAL_ESCRIPTS) $(LINKED_ESCRIPTS)

# Record the build and link dependency: the target files are linked to
Expand All @@ -56,8 +57,9 @@ rabbitmq-plugins = escript/rabbitmqctl
rabbitmq-diagnostics = escript/rabbitmqctl
rabbitmq-queues = escript/rabbitmqctl
rabbitmq-streams = escript/rabbitmqctl
rabbitmq-tanzu = escript/rabbitmqctl
rabbitmq-upgrade = escript/rabbitmqctl
escript/rabbitmq-plugins escript/rabbitmq-diagnostics escript/rabbitmq-queues escript/rabbitmq-streams escript/rabbitmq-upgrade: escript/rabbitmqctl
escript/rabbitmq-plugins escript/rabbitmq-diagnostics escript/rabbitmq-queues escript/rabbitmq-streams escript/rabbitmq-tanzu escript/rabbitmq-upgrade: escript/rabbitmqctl

# We use hardlinks or symlinks in the `escript` directory and
# install's PREFIX when a single escript can have several names (eg.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.HelpCommand do

@behaviour RabbitMQ.CLI.CommandBehaviour

def scopes(), do: [:ctl, :diagnostics, :plugins, :queues, :upgrade]
def scopes(), do: [:ctl, :diagnostics, :plugins, :queues, :tanzu, :upgrade]
def switches(), do: [list_commands: :boolean]

def distribution(_), do: :none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## License, v. 2.0. If a copy of the MPL was not distributed with this
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
##
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
## Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.


defmodule ClearGlobalParameterCommandTest do
Expand All @@ -15,7 +15,7 @@ defmodule ClearGlobalParameterCommandTest do

setup_all do
RabbitMQ.CLI.Core.Distribution.start()

:ok
end

Expand Down
4 changes: 2 additions & 2 deletions deps/rabbitmq_cli/test/ctl/clear_policy_command_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## License, v. 2.0. If a copy of the MPL was not distributed with this
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
##
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
## Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.


defmodule ClearPolicyCommandTest do
Expand All @@ -17,7 +17,7 @@ defmodule ClearPolicyCommandTest do

setup_all do
RabbitMQ.CLI.Core.Distribution.start()

add_vhost @vhost

enable_federation_plugin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
// Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
//

package com.rabbitmq.mqtt.test;
Expand Down Expand Up @@ -705,7 +705,7 @@ public Socket createSocket() {

// let last will propagate after disconnection
waitForTestDelay();

client2.connect(client2_opts);
client2.setCallback(this);
client2.subscribe(retainedTopic, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
%%
%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
%% Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
%%

[
Expand All @@ -20,7 +20,7 @@
]}
], [rabbitmq_peer_discovery_etcd]
},

{etcd_discovery_mechanism_shortcut,
"cluster_formation.peer_discovery_backend = etcd
cluster_formation.etcd.host = etcd.eng.megacorp.local", [
Expand All @@ -34,7 +34,7 @@
]}
], [rabbitmq_peer_discovery_etcd]
},

%% etcd hostname
{etcd_host, "cluster_formation.etcd.host = etcd.eng.megacorp.local", [
{rabbit, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
%%
%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
%% Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
%%

[
Expand All @@ -19,7 +19,7 @@
]}
], [rabbitmq_peer_discovery_k8s]
},

{k8s_discovery_mechanism_as_alias1,
"cluster_formation.peer_discovery_backend = k8s
cluster_formation.k8s.host = k8s.eng.megacorp.local", [
Expand All @@ -33,7 +33,7 @@
]}
], [rabbitmq_peer_discovery_k8s]
},

{k8s_discovery_mechanism_as_alias2,
"cluster_formation.peer_discovery_backend = kubernetes
cluster_formation.k8s.host = k8s.eng.megacorp.local", [
Expand All @@ -47,7 +47,7 @@
]}
], [rabbitmq_peer_discovery_k8s]
},

{k8s_host, "cluster_formation.k8s.host = k8s.eng.megacorp.local", [
{rabbit, [
{cluster_formation, [
Expand Down
1 change: 1 addition & 0 deletions dist.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def _versioned_rabbitmq_home_impl(ctx):
"rabbitmq-plugins",
"rabbitmq-queues",
"rabbitmq-streams",
"rabbitmq-tanzu",
"rabbitmq-upgrade",
"rabbitmqctl",
]
Expand Down
1 change: 1 addition & 0 deletions rabbitmq_home.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def _impl(ctx):
"rabbitmq-plugins",
"rabbitmq-queues",
"rabbitmq-streams",
"rabbitmq-tanzu",
"rabbitmq-upgrade",
"rabbitmqctl",
]
Expand Down

0 comments on commit f7d32d6

Please sign in to comment.