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

Filter out from properties of tags object. #1107

Merged
merged 11 commits into from
Apr 20, 2018
5 changes: 4 additions & 1 deletion azurerm/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ func flattenAndSetTags(d *schema.ResourceData, tagsMap map[string]*string) {
output := make(map[string]interface{}, len(tagsMap))

for i, v := range tagsMap {
output[i] = *v
// Filter out $type from tags object to avoid unexpected change on plan.
if i != "$type" {
output[i] = *v
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's best to filter this on the individual resource where this needs to be filtered out (as people may have a legitimate use for the $type tag) - can we instead filter this out on the resource before calling this function? e.g.

tagsToOutput := make([]string, 0)
for i, v := range resp.Tags {
  tag = *v
  // Filter out $type from tags object to avoid unexpected change on plan.
  if tag != "$type" {
    tagsToOutput[i] = tag
  }
}

in addition - can we add some validation to ensure that the $type tag can't be added on that resource? We can do this using a ValidateFunc on the tags schema item for this resource :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the code and tests.

}

d.Set("tags", output)
Expand Down