Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'kubectl rabbitmq version' sub command #450

Merged
merged 1 commit into from
Nov 9, 2020
Merged

Conversation

ansd
Copy link
Member

@ansd ansd commented Nov 9, 2020

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:

Remarks:
Redirecting the output of this command to a program or file will only print the names of the plugins installed

Therefore, we parse the rabbitmq plugin version from the krew list logs by increasing the verbosity to 4.

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).

Copy link
Contributor

@ChunyiLyu ChunyiLyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@ablease ablease self-requested a review November 9, 2020 15:45
Copy link
Contributor

@ablease ablease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, thanks David!

@ansd ansd merged commit a456659 into main Nov 9, 2020
@ansd ansd deleted the kubectl-rabbitmq-version branch November 9, 2020 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants