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

Add resource manager tags to GKE autopilot #7162

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/10123.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
container: added `node_pool_auto_config.resource_manager_tags` field to `google_container_cluster` resource
```
1 change: 0 additions & 1 deletion google-beta/services/container/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,6 @@ func flattenResourceManagerTags(c *container.ResourceManagerTags) map[string]int
for k, v := range c.Tags {
rmt[k] = v
}

}

return rmt
Expand Down
30 changes: 30 additions & 0 deletions google-beta/services/container/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,11 @@ func ResourceContainerCluster() *schema.Resource {
},
},
},
"resource_manager_tags": {
Type: schema.TypeMap,
Optional: true,
Description: `A map of resource manager tags. Resource manager tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456. The field is ignored (both PUT & PATCH) when empty.`,
},
},
},
},
Expand Down Expand Up @@ -4103,6 +4108,24 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
log.Printf("[INFO] GKE cluster %s node pool auto config network tags have been updated", d.Id())
}

if d.HasChange("node_pool_auto_config.0.resource_manager_tags") {
rmtags := d.Get("node_pool_auto_config.0.resource_manager_tags")

req := &container.UpdateClusterRequest{
Update: &container.ClusterUpdate{
DesiredNodePoolAutoConfigResourceManagerTags: expandResourceManagerTags(rmtags),
},
}

updateF := updateFunc(req, "updating GKE cluster node pool auto config resource manager tags")
// Call update serially.
if err := transport_tpg.LockedCall(lockKey, updateF); err != nil {
return err
}

log.Printf("[INFO] GKE cluster %s node pool auto config resource manager tags have been updated", d.Id())
}

d.Partial(false)

if d.HasChange("cluster_telemetry") {
Expand Down Expand Up @@ -5351,6 +5374,10 @@ func expandNodePoolAutoConfig(configured interface{}) *container.NodePoolAutoCon
npac.NetworkTags = expandNodePoolAutoConfigNetworkTags(v)
}

if v, ok := config["resource_manager_tags"]; ok && len(v.(map[string]interface{})) > 0 {
npac.ResourceManagerTags = expandResourceManagerTags(v)
}

return npac
}

Expand Down Expand Up @@ -6148,6 +6175,9 @@ func flattenNodePoolAutoConfig(c *container.NodePoolAutoConfig) []map[string]int
if c.NetworkTags != nil {
result["network_tags"] = flattenNodePoolAutoConfigNetworkTags(c.NetworkTags)
}
if c.ResourceManagerTags != nil {
result["resource_manager_tags"] = flattenResourceManagerTags(c.ResourceManagerTags)
}

return []map[string]interface{}{result}
}
Expand Down
Loading