Skip to content

[CLOUDP-332196] Move kubectl-mongodb plugin to cmd dir for atomic releases #271

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

viveksinghggits
Copy link
Contributor

@viveksinghggits viveksinghggits commented Jul 16, 2025

Summary

In the efforts towards atomic releases this PR tries to move the kubectl-mongodb plugin code from the directory public/tools/multicluster to the root of the project cmd/. This is to align the project with how other Go based projects are structured.
Apart from that this PR also moves the .goreleaser.yaml for the kubectl-mongodb plugin from public/tools/multicluster/.goreleaser.yaml directory to the root of the repo. This is also done in order to align how .goreleaser.yaml is kept in other Go based opensource projects.
This PR also moves the evergreen file that releases kubectl-mongodb plugin from the location public/.evergreen.yml to the root of the repo and is renamed to .evergreen-kubectlplugin.yml. This is to make sure the evergreen files are kept at the same location, i.e. the root of the repo.

Note on LICENSE-THIRD-PARTY

The licenses that are used by the third party go libraries that we use in our kubectl plugin, are documented in public docs at this link.
When we generated the file (LICENSE-THIRD-PARTY) after moving the kubectl-mongodb code to cmd/ directory, we can only see a new package added, that is sigs.k8s.io/yaml/goyaml this seems to be part of the module sigs.k8s.io/yaml which was already part of the LICENSE-THIRD-PARTY, that's why we don't need to re-publish the docs for third party licenses.

To generate the LICENSE-THIRD-PARTY, make precommit can be run after setting env var export MDB_UPDATE_LICENSES=true.

This PR also fixes https://jira.mongodb.org/browse/CLOUDP-332234

Proof of Work

Run goreleaser command locally and verify the binaries that are generated in the dist directory that they output the correct subcommands.

~/work/opensource/mongodb-kubernetes/dist/kubectl-mongodb_darwin_arm64_v8.0 (mongodb-kubectlplugin-refactor*) » ./kubectl-mongodb                             
This application is a tool to simplify maintenance tasks
of MongoDB resources in your kubernetes cluster.

Build: 1cd782d97de76ed25d6170a1d0aaa50382022c08, 2025-07-17T12:10:32Z

Usage:
  kubectl-mongodb [command]

Available Commands:
  completion   Generate the autocompletion script for the specified shell
  debug        Downloads all resources required for debugging and stores them into the disk
  help         Help about any command
  multicluster Manage MongoDB multicluster environments on k8s

Flags:
  -h, --help   help for kubectl-mongodb

Use "kubectl-mongodb [command] --help" for more information about a command.

Testing via evergreen:
Since we are experiencing some issues while testing the entire release process I am planning to merge this PR to master and then would test the release from master.

Jira: https://jira.mongodb.org/browse/CLOUDP-332196

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you checked for release_note changes?

Reminder (Please remove this when merging)

  • Please try to Approve or Reject Changes the PR, keep PRs in review as short as possible
  • Our Short Guide for PRs: Link
  • Remember the following Communication Standards - use comment prefixes for clarity:
    • blocking: Must be addressed before approval.
    • follow-up: Can be addressed in a later PR or ticket.
    • q: Clarifying question.
    • nit: Non-blocking suggestions.
    • note: Side-note, non-actionable. Example: Praise
    • --> no prefix is considered a question

@viveksinghggits viveksinghggits force-pushed the mongodb-kubectlplugin-refactor branch from 198327f to de60a3e Compare July 16, 2025 16:09
…ster

This commit moves the source code of mongodb kubectl plugin from `public/tools/multicluster`
to `cmd` directory. This is to align with how go code that ships a CLI is structured.

The command/subcommand building logic is moved to the `cmd` directory and and rest of the logic

The command/subcommand building logic is moved to the `cmd` directory and and rest of the logic
is moved to the new package `pkg/kubectl-mongodb`.

This commit also moves the `.goreleaser.yaml` to the root of the project because kubectl plugin
is now at the root of the project.
@viveksinghggits viveksinghggits force-pushed the mongodb-kubectlplugin-refactor branch from de60a3e to 02b94d0 Compare July 16, 2025 16:10
1. Since most of our evergreen config files are in root of the repo and now that kubectl plugin
is also moved to `cmd/` it makes sense to move the evergreen config file to the root of repo
with correct name.
2. Change the goreleaser config file to version 1. We upgraded it temporarily to  version 2
but CI complains that only version 1 is supported.
@viveksinghggits viveksinghggits force-pushed the mongodb-kubectlplugin-refactor branch from 94fab09 to 1884f19 Compare July 17, 2025 17:48
@viveksinghggits viveksinghggits marked this pull request as ready for review July 17, 2025 18:06
@viveksinghggits viveksinghggits requested a review from a team as a code owner July 17, 2025 18:06
viveksinghggits added a commit that referenced this pull request Jul 17, 2025
The evergreen function `build_multi_cluster_binary` is used to build the `kubectl-mongodb` plugin. And this function
gets used in the main `.evergreen.yml` file to build the `kubectl-mongodb` binary.
Since we moved the location of the source files for `kubectl-mongodb` plugin as part of [PR](#271),
this PR makes respective changes in the evergreen function so that it can properly build the `kubectl-mongodb` plugin from
the new location.
@MaciejKaras
Copy link
Collaborator

Thanks for very well documented PR!

Some general notes:

  • please add ticket number to PR title similar to other PRs, example
  • init_test_run/build_test_image task fails, it cannot build mcli for test usage
  • you need to run .githooks/pre-commit in order to fix linter issues

@viveksinghggits
Copy link
Contributor Author

Thank you for the feedback @MaciejKaras.

init_test_run/build_test_image task fails, it cannot build mcli for test usage

Right, we knew think is going to happen and I have raised the change as part of the other PR #275 which is based on this PR, to make things easy to review.

I will work on other comments.

@viveksinghggits viveksinghggits changed the title Move kubectl-mongodb plugin to cmd dir for atomic releases [CLOUDP-332196] Move kubectl-mongodb plugin to cmd dir for atomic releases Jul 18, 2025
Since we moved the code of `kubectl-mongodb` plugin to `cmd/` we needed
to move the licenses files to the new location.
This commit does that.
@viveksinghggits
Copy link
Contributor Author

@MaciejKaras can you please have a look into this PR again?

Copy link
Collaborator

@MaciejKaras MaciejKaras left a comment

Choose a reason for hiding this comment

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

The refactor looks really good!

Please also check and update old multicluster usages in other files. Examples I found:

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.

2 participants