-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_container_registry - deprecating the georeplication_locations property in favour of the georeplications property #11200
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ms-henglu thank you for opening this PR!
This basically looks good to me 👍 aside from some inline comments and some recommendations on test case enhancement, please take a look, thanks
Optional: true, | ||
Computed: true, // TODO -- remove this when deprecation resolves | ||
ConflictsWith: []string{"georeplication_locations"}, | ||
ConfigMode: schema.SchemaConfigModeAttr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add some comments to describe the reason for this attribute here?
And also this also need a TODO -- remove in 3.0
comment.
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
ValidateFunc: validation.StringIsNotEmpty, | ||
}, | ||
Set: location.HashCode, | ||
}, | ||
|
||
"georeplications": { | ||
Type: schema.TypeList, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need this to be a Set considering that we are using Set for the attribute georeplication_locations
which we are replacing with this new block? Or List could meet the requirement here, the Set for georeplication_locations
is an overkill?
To determine this, would the service accept an input with two elements with the same location but different tags?
Or would the service always return the response in the same order as the request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think List is enough, since service always return the response in the same order as the request.
ref: https://github.com/microsoft/terraform-provider-azurerm/wiki/R-1006
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another reason to use list, is that there's an issue about optional-computed set, state won't be updated after applying, unless refresh.
hashicorp/terraform-plugin-sdk#618
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If order doesn't matter this should be a set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it to set.
if geoReplicationLocations != nil && geoReplicationLocations.Len() > 0 { | ||
// the ACR is being created so no previous geo-replication locations | ||
oldGeoReplicationLocations := []interface{}{} | ||
err = applyGeoReplicationLocations(d, meta, resourceGroup, name, oldGeoReplicationLocations, geoReplicationLocations.List()) | ||
var oldGeoReplicationLocations []*containerregistry.Replication | ||
err = applyGeoReplicationLocations(d, meta, resourceGroup, name, oldGeoReplicationLocations, expandReplicationsFromLocations(geoReplicationLocations.List())) | ||
if err != nil { | ||
return fmt.Errorf("Error applying geo replications for Container Registry %q (Resource Group %q): %+v", name, resourceGroup, err) | ||
} | ||
} | ||
// geo replications have been specified | ||
if len(geoReplications) > 0 { | ||
// the ACR is being created so no previous geo-replication locations | ||
var oldGeoReplicationLocations []*containerregistry.Replication | ||
err = applyGeoReplicationLocations(d, meta, resourceGroup, name, oldGeoReplicationLocations, expandReplications(geoReplications)) | ||
if err != nil { | ||
return fmt.Errorf("Error applying geo replications for Container Registry %q (Resource Group %q): %+v", name, resourceGroup, err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part looks a bit redundant - could we combine these two if's by saying first determine the newGeoReplicationLocations
and then call the applyGeoReplicationLocations
to apply them? It helps to make things more clear here
Check: resource.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
check.That(data.ResourceName).Key("sku").HasValue(skuBasic), | ||
check.That(data.ResourceName).Key("georeplication_locations.#").HasValue("0"), | ||
check.That(data.ResourceName).Key("georeplications.#").HasValue("0"), | ||
), | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that we could introduce a update case to update only the tags
propertyin the
geoReplicationLocation? also could we add a case with multiple location entries with the corresponding update cases? Finally to make sure this would not break our existing customer - could we add a test case that ensures if we switch the config written using
georeplication_locationsto a config written using
georeplications` will give us no-diff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the advice.
I updated the tests to test
- tags
- multiple locations
- switch from georeplication_locations to georeplications
@@ -58,6 +58,14 @@ The following arguments are supported: | |||
|
|||
~> **NOTE:** The `georeplication_locations` list cannot contain the location where the Container Registry exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COuld we also add the deprecation information to follow the Optional
? Like this:
georeplication_locations
- (Optional / Deprecated in favor ofgeoreplications
) A list of Azure locations where the container registry should be geo-replicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also can just remove it, but either works
d952835
to
c77fdad
Compare
@ArcturusZhang hi, I have added a commit to add more tests and fix some issues. Please review again, thanks! |
efdf3f1
to
93e39ab
Compare
@katbyte hi, I change the type to set, please check again, thanks! |
Hey @ms-henglu looks like we are having conflicts in this PR now, could you please resolve the conflict? |
93e39ab
to
e08fb47
Compare
@ArcturusZhang hi, thanks! I have resolved the conflicts by removing latest commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from a couple minor comments this LGTM 👍
} | ||
|
||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-aks-%d" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't aks?
name = "acctestRG-aks-%d" | |
name = "acctestRG-acr-%d" |
@@ -58,6 +58,14 @@ The following arguments are supported: | |||
|
|||
~> **NOTE:** The `georeplication_locations` list cannot contain the location where the Container Registry exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also can just remove it, but either works
|
||
* `location` - (Required) A location where the container registry should be geo-replicated. | ||
|
||
* `tags` - (Optional) A mapping of tags to assign to the container registry replication resource. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phrasing
* `tags` - (Optional) A mapping of tags to assign to the container registry replication resource. | |
* `tags` - (Optional) A mapping of tags to assign to this replication location. |
} | ||
|
||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-aks-%d" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name = "acctestRG-aks-%d" | |
name = "acctestRG-acr-%d" |
} | ||
|
||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-aks-%d" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
} | ||
|
||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-aks-%d" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
@katbyte ,hi, I add one commit to fix it, please check again, thanks! |
This has been released in version 2.57.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 2.57.0"
}
# ... other configuration ... |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
The test results are listed as follows.