Skip to content

Conversation

lantoli
Copy link
Collaborator

@lantoli lantoli commented Aug 12, 2025

Description

Create advancedClusterToV2 command skeleton.

  • Add unit & e2e test infra for the new command
  • Many code and test refactors to reduce duplication and have common logic for both CLI commands
  • Use aliases in CLI manifest file
  • Transformation logic will be implement in follow-up PRs
  • Documentation will be updated in follow-up PRs

Link to any related issue(s): CLOUDP-337602

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@github-actions github-actions bot added the enhancement New feature or request label Aug 12, 2025
@lantoli lantoli marked this pull request as ready for review August 13, 2025 09:06
@Copilot Copilot AI review requested due to automatic review settings August 13, 2025 09:06
@lantoli lantoli requested a review from a team as a code owner August 13, 2025 09:06
Copy link
Contributor

@Copilot Copilot AI left a 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 creates the skeleton for a new advancedClusterToNew command that will convert MongoDB Atlas advanced cluster configurations from provider version 1.X.X (SDKv2) to version 2.X.X (TPF - Terraform Plugin Framework). The implementation focuses on establishing the command structure and test infrastructure while deferring the actual transformation logic to future PRs.

  • Adds the new adv2new command with basic CLI structure and parameter validation
  • Refactors existing code to extract common functionality shared between CLI commands
  • Creates comprehensive test infrastructure for both unit and e2e testing of the new command

Reviewed Changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cmd/plugin/main.go Registers the new adv2new command with the CLI
internal/cli/common.go Extracts shared CLI functionality into reusable BaseOpts struct
internal/cli/clu2adv/clu2adv.go Refactors to use shared CLI functionality
internal/cli/adv2new/adv2new.go Implements the new command using shared CLI patterns
internal/convert/adv2new.go Creates placeholder conversion function
test/e2e/e2e_helper.go Adds shared test infrastructure for both commands
test/e2e/clu2adv_test.go Refactors to use shared test infrastructure
test/e2e/adv2new_test.go Implements e2e tests for the new command
internal/convert/convert_test.go Refactors to support testing multiple commands
Various testdata files Adds test fixtures for the new command

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Convert: convert.AdvancedClusterToNew,
}
cmd := &cobra.Command{
Use: "advancedClusterToNew",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Use: "advancedClusterToNew",
Use: "advancedClusterV2",

just for sanity, how would the full command look like?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

some equivalent examples to use it with names or aliases are:

atlas tf adv2new -f example.in.tf -o example.out.tf
atlas terraform advancedClusterToNew --file example.in.tf --output example.out.tf

# current cluster to adv_cluster command
atlas tf clu2adv -f example.in.tf -o example.out.tf
atlas terraform clusterToAdvancedCluster --file example.in.tf --output example.out.tf

you can also mix names and aliases in the same command

I like the convert command pattern name of xxxToyyy and alias x2y, maybe advancedClusterToV2 and adv2v2 ? (not convinced with so many 2, that's why i tried to avoid 2 in the command name).

Having this context, what command and alias do you think it's better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@marcosuma let me know if it's ok that I keep the current name and alias at the moment and I merge the PR as it is, or you prefer to use a different alias and name

Copy link
Contributor

Choose a reason for hiding this comment

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

Not blocking this PR, but I think New and Latest quickly become obsolete or ambiguous, that's why ...ToV2 I like it more. 2v2 is not ideal, but that's also an alias so I am less concerned

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's fair, changed here: 32398ac

@@ -0,0 +1,130 @@
package cli
Copy link
Contributor

Choose a reason for hiding this comment

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

nice re-use!

Copy link
Contributor

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

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

Excellent re-use!

@lantoli
Copy link
Collaborator Author

lantoli commented Aug 13, 2025

Excellent re-use!

@EspenAlbert thanks :-) it's what took most of the time in the PR

@lantoli lantoli merged commit 6c18dc0 into main Aug 13, 2025
7 checks passed
@lantoli lantoli deleted the CLOUDP-337602_command branch August 13, 2025 12:26
@lantoli lantoli changed the title feat: Create advancedClusterToNew command skeleton feat: Create advancedClusterToV2 command skeleton Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants