Skip to content

INTMDB-185: Added parameter regions for GCP network container #418

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

Merged
merged 4 commits into from
Mar 9, 2021

Conversation

coderGo93
Copy link
Contributor

Description

  • Added a parameter regions for GCP in resource/datasource(s) of network container
  • Added test TestAccResourceMongoDBAtlasNetworkContainer_WithRegionsGCP
  • Added test TestAccDataSourceMongoDBAtlasNetworkContainer_WithGCPRegions
  • Added test TestAccDataSourceMongoDBAtlasNetworkContainer_WithGCPRegions

Link to any related issue(s):

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the Terraform contribution guidelines
  • 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

Further comments

Before the atlas client should be released first so I can updated the go.mod with official tag instead of auto generated with go get

@coderGo93 coderGo93 requested review from themantissa and leofigy March 6, 2021 01:28
@coderGo93 coderGo93 self-assigned this Mar 6, 2021
Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

LGTM - needs DOU review and good to merge. Thank you!

@@ -61,6 +61,13 @@ func dataSourceMongoDBAtlasNetworkContainer() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"regions": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's a data source but question, this will returned by all the types ?

@@ -124,6 +131,10 @@ func dataSourceMongoDBAtlasNetworkContainerRead(d *schema.ResourceData, meta int
return fmt.Errorf("error setting `vnet_name` for Network Container (%s): %s", d.Id(), err)
}

if err = d.Set("regions", container.Regions); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I mean , if it's azure, aws or gcp, the api returns always the regions field? (even empty)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, if not using, it will not appear in response neither in state, for now it can be only used for gcp, for azure is the singular region

Copy link
Contributor

Choose a reason for hiding this comment

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

yea, I see the client code, curious do we get any warning, because moving from nil to empty type?
Regions []string json:"regions,omitempty" // Regions are available for GCP

@@ -70,6 +70,13 @@ func dataSourceMongoDBAtlasNetworkContainers() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"regions": {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Contributor

@leofigy leofigy left a comment

Choose a reason for hiding this comment

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

LGTM just confirm the regions field is not affected in the set for azure or gcp.

And do a negative testing , create an azure and set the regions field.
I know it's late , but all these fields with the same names ,
region, region_name, regions is really confusing

would not be better to have like an gcp_regions , or subobject for

gcp {
regions = []
}

@coderGo93
Copy link
Contributor Author

coderGo93 commented Mar 9, 2021

LGTM just confirm the regions field is not affected in the set for azure or gcp.

And do a negative testing , create an azure and set the regions field.
I know it's late , but all these fields with the same names ,
region, region_name, regions is really confusing

would not be better to have like an gcp_regions , or subobject for

gcp {
regions = []
}

You can put regions using azure but it will not send in request because it's validated to only in gcp like azure with region or aws with region_name in create function, also if you do that you could get an update-in-change behavior in the re apply.

@coderGo93 coderGo93 added the run-testacc To run acceptance tests label Mar 9, 2021
@coderGo93 coderGo93 merged commit 98097d2 into master Mar 9, 2021
@coderGo93 coderGo93 deleted the INTMDB-185 branch March 9, 2021 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-testacc To run acceptance tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants