Add 'kubectl rabbitmq version' sub command #450
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates #440.
Since we require the kubectl rabbitmq plugin to be installed via krew, the easiest way to output the plugin version is to ask krew. As explained in the commit message
kubectl krew info rabbitmq
will output the available - not installed - version. In contrast,kubectl krew list
outputs the installed version.As explained in
kubectl krew list --help
:Therefore, we parse the rabbitmq plugin version from the
krew list
logs by increasing the verbosity to4
.If the rabbitmq plugin is not installed via krew, the command will output an appropriate error message.
I wrote the tests such that they don't require
krew
to be installed. If krew isn't installed, we simply test for the error message.Caveats:
If the rabbitmq plugin is installed via krew, but the script is not invoked via krew (e.g.
cluster-operator/bin/kubectl-rabbitmq
takes precedence over/usr/local/bin/kubectl-krew
in PATH), the rabbitmq plugin version of krew will still be output. I think that's a minor issue for us developers, but not for end users.Alternative approach:
Have some version variable hard coded in the bash script. Include a task in our Concourse release job which bumps that version and commits right before tagging. This approach seems to be more brittle because that task needs to commit directly to the
main
branch which introduces other difficulties (as have have experienced from our BOSH release pipelines).