Skip to content

Conversation

lantoli
Copy link
Collaborator

@lantoli lantoli commented Feb 20, 2025

Description

Converts data sources

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

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 Feb 20, 2025
@lantoli lantoli marked this pull request as ready for review February 20, 2025 09:00
@lantoli lantoli requested a review from a team as a code owner February 20, 2025 09:00
Copy link
Contributor

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

LGTM however we should double check if we want to generate the use_replication_spec_per_shard attribute

Comment on lines 48 to 49
for _, resource := range parser.Body().Blocks() {
labels := resource.Labels()
resourceName := labels[0]
if resource.Type() != resourceType || resourceName != cluster {
continue
}
resourceb := resource.Body()
if errDyn := checkDynamicBlock(resourceb); errDyn != nil {
return nil, errDyn
}
labels[0] = advCluster
resource.SetLabels(labels)

if resourceb.FirstMatchingBlock(nRepSpecs, nil) != nil {
err = fillCluster(resourceb)
} else {
err = fillFreeTierCluster(resourceb)
}
converted, err := convertResource(resource)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the resource variable name confused me here, this would be a block which can be a resource or data source right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks, changed here: b1d2a2b

Comment on lines 1 to 9
data "mongodbatlas_advanced_cluster" "singular" {
# data source content is kep, only data source type is changed - singular
project_id = mongodbatlas_advanced_cluster.example.project_id
name = mongodbatlas_advanced_cluster.example.name
depends_on = [mongodbatlas_privatelink_endpoint_service.example_endpoint]

# Generated by atlas-cli-plugin-terraform.
# Please confirm that all references to this resource are updated.
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we include use_replication_spec_per_shard = true? Might be the most consistent output given we generated advanced_cluster resources with single replication spec per shard (no use of num_shards).

Copy link
Contributor

Choose a reason for hiding this comment

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

yes we should because eventually in 2.0 use_replication_spec_per_shard = true becomes the standard, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

correct, added this into the v2 release doc as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

great point, added here: 9297c5f

Copy link
Contributor

@marcosuma marcosuma left a comment

Choose a reason for hiding this comment

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

LGTM overall - only one aspect related to use_replication_spec_per_shard = true

project_id = mongodbatlas_advanced_cluster.example.project_id
name = mongodbatlas_advanced_cluster.example.name
depends_on = [mongodbatlas_privatelink_endpoint_service.example_endpoint]
use_replication_spec_per_shard = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice to use the new format 👍

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.

LGTM!

@lantoli lantoli merged commit cb5edda into main Feb 20, 2025
6 checks passed
@lantoli lantoli deleted the CLOUDP-301789_data_sources branch February 20, 2025 12:25
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.

4 participants