-
Notifications
You must be signed in to change notification settings - Fork 310
Rewrite kubectl plugin in Go #2036
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
Conversation
This commit adds a first version of kubectl-rabbitmq plugin. This is an effort to move away from the Bash version of kubectl-rabbitmq, which has some limitations and known quirks.
Because otherwise tests may take up to the timeout to fail
This commit also updates the default installation to use GHCR
Adding additional coverage, and more flexibility to run tests via Makefile
The plugin is now a Go application. It has its own Go tests and build system. The plugin version is aligned with the cluster operator version.
Because the cli is single-module, and its code is not reusable by external programs.
be18696 to
04e114c
Compare
04e114c to
b0a2df7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR rewrites the kubectl-rabbitmq plugin from Bash to Go, providing a more maintainable and testable codebase with comprehensive command coverage.
Changes:
- Complete rewrite of kubectl plugin from Bash shell script to Go using cobra framework
- Added comprehensive unit and integration test coverage
- Updated CI/CD pipeline to build and release cross-platform binaries (darwin/linux, amd64/arm64)
Reviewed changes
Copilot reviewed 2 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| bin/kubectl-rabbitmq-plugin/main.go | New Go entry point with cobra command structure |
| bin/kubectl-rabbitmq-plugin/commands.go | Implements all plugin commands (create, list, delete, manage, etc.) |
| bin/kubectl-rabbitmq-plugin/kubectl.go | Kubectl command executor with namespace handling |
| bin/kubectl-rabbitmq-plugin/cluster.go | RabbitMQ cluster building and YAML generation |
| bin/kubectl-rabbitmq-plugin/jobs.go | Performance test job creation |
| bin/kubectl-rabbitmq-plugin/credentials.go | Credential fetching from Kubernetes secrets |
| bin/kubectl-rabbitmq-plugin/*_test.go | Comprehensive unit and integration tests |
| bin/kubectl-rabbitmq-plugin/go.mod | Go module definition with dependencies |
| bin/kubectl-rabbitmq-plugin/Makefile | Build and test automation |
| bin/kubectl-rabbitmq | Removed old Bash implementation |
| bin/kubectl-rabbitmq.bats | Removed old Bash tests |
| hack/rabbitmq.yaml | Updated krew plugin manifest for binary distribution |
| .github/workflows/build-test-publish.yml | CI pipeline updates for building and releasing plugin |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MirahImage
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My one recommendation would be to include a dependabot group for the kubectl-rabbitmq-plugin. Otherwise, looks good
Co-authored-by: Copilot <[email protected]>
Note to reviewers: remember to look at the commits in this PR and consider if they can be squashed
Summary Of Changes
Additional Context
The kubectl plugin is its own Go module. The cluster-operator version is always the local repo (observe the
replacedirective in Go mod). There are integration tests that create rabbits in a local Kubernetes(KinD). The coverage shows a sad 30%, however, it's not considering the statement hits by the integration tests, because those build the binary and call it viaos.Exec; this dodges the coverage accounting.The command to create rabbits has been extended to cover almost any possible option in the spec. The override is left out, because that feature is too complex to support in a CLI flag.
Local Testing
Make sure you
cdinto the plugin directory:cd bin/kubectl-rabbitmq-plugin/To run unit tests:
make testsTo run all tests, including integration:
make tests TEST_TAGS="integration"Make sure you have a Kubernetes environment accessible in your current kubectl context.