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

feat: Adds mongodbatlas_project_ip_addresses data source #2533

Merged
merged 17 commits into from
Sep 4, 2024

Conversation

rubenVB01
Copy link
Contributor

@rubenVB01 rubenVB01 commented Aug 28, 2024

Description

In this PR I implement the new mongodbatlas_project_ip_addresses Data Source. This PR includes the implementation, testing and documentation. As a follow-up, there will also be a deprecation for the ip_addresses attribute in the project resource and data source.

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

Agustin Edit:
Using the following configuration

data "mongodbatlas_project_ip_addresses" "with-cluster" {
  project_id = var.project_id
}

Verified all possible scenarios:

  • no clusters
  • cluster being created which returns a cluster element with empty ip addresses
  • cluster after creation which defined inbound and outbound ip addresses

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

@rubenVB01 rubenVB01 requested a review from a team as a code owner August 28, 2024 08:29
@oarbusi
Copy link
Collaborator

oarbusi commented Aug 28, 2024

Good work, some things to take into account:

  • Tests should be included in this PR and ideally make the test run in the CI, if not, we can't be 100% sure that what is being merged to master is working as we expect.
  • when a feat PR is created, a changelog entry must be included in the PR, check this guide
  • PR title does not need to include Cloudp 262915, you could change it to "feat: Adds mongodbatlas_project_ip_addresses data source"

@rubenVB01 rubenVB01 requested a review from a team as a code owner August 28, 2024 09:29
@rubenVB01 rubenVB01 changed the title feat: Cloudp 262915 project_ip_addresses data source implementation feat: Adds mongodbatlas_project_ip_addresses data source Aug 28, 2024
Config: ProjectIPAddressesConfig(projectID),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet(dataSourceName, "project_id"),
resource.TestCheckResourceAttr(dataSourceName, "services.clusters.#", "0"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we have a test where a cluster is created in the project and it has some inbound and outbound ip addresses?

Copy link
Member

Choose a reason for hiding this comment

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

have my doubts if we want to include a cluster creation/deletion for this, considering we do have a unit test that verifies correct handling of a complete response with ip addresses. No strong opinion, looping in @lantoli @maastha @EspenAlbert @marcosuma in case there is additional inputs.

Copy link
Member

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

some additional points to consider

.changelog/2533.txt Outdated Show resolved Hide resolved
internal/service/projectipaddresses/model_test.go Outdated Show resolved Hide resolved
internal/service/projectipaddresses/data_source_schema.go Outdated Show resolved Hide resolved
@AgustinBettati AgustinBettati changed the title feat: Adds mongodbatlas_project_ip_addresses data source feat: Adds mongodbatlas_project_ip_addresses data source Sep 3, 2024
Copy link
Collaborator

@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

@@ -0,0 +1,3 @@
```release-note:new-datasource
data-source/mongodbatlas_project_ip_addresses
Copy link
Member

@lantoli lantoli Sep 3, 2024

Choose a reason for hiding this comment

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

@AgustinBettati knit: this seems like a singular ds, i see API endpoint is in plural, but wonder if we should call this ds mongodbatlas_project_ip_address.

as an example this ds doesn't seem to have the normal attributes of a plural ds such as results

Copy link
Member

Choose a reason for hiding this comment

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

Good call out.
Definitely not our regular case of plural data source with results. I was taking inspiration from mongodbatlas_control_plane_ip_addresses that is similar in the sense that is it an isolated data source associated to single get endpoint, and API is not using regular pagination to return all results. As both of them return multiple ip addresses thought this name would be more appropriate.

@AgustinBettati AgustinBettati merged commit b742975 into master Sep 4, 2024
35 checks passed
@AgustinBettati AgustinBettati deleted the CLOUDP-262915 branch September 4, 2024 08:20
svc-apix-Bot added a commit that referenced this pull request Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants