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 support to 'google_container_cluster' #9531

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3421c4a
resourceManagerTags added to Cluster Node Config schema
maxi-cit Nov 28, 2023
dc59126
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Nov 28, 2023
70c6d69
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Dec 4, 2023
44ee4ec
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Dec 6, 2023
a38b7bf
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Dec 11, 2023
77b5c02
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Dec 12, 2023
3e75da5
update beta tag
maxi-cit Dec 18, 2023
38f43fb
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Dec 18, 2023
8084d1a
add cluster and node proto tests
maxi-cit Dec 18, 2023
53f5150
add expand and flatten proto
maxi-cit Dec 18, 2023
f8046d7
removed beta tag
maxi-cit Dec 19, 2023
9ef5388
added to documentation
maxi-cit Dec 19, 2023
18e5a9c
added resource manager tags to auto pilot
maxi-cit Dec 19, 2023
e5ab6db
Merge branch 'main' into add-resource-manager-to-cluster
maxi-cit Jan 2, 2024
481eda7
migrating resourceManagerTags tests
maxi-cit Jan 3, 2024
9ef00f6
migrating node_pools test
maxi-cit Jan 4, 2024
6b1839a
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Jan 9, 2024
14f4fcb
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Jan 10, 2024
1f473b4
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Jan 12, 2024
581557f
migrating additional tests
maxi-cit Jan 17, 2024
428051e
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Jan 27, 2024
4284843
minor fixes
maxi-cit Jan 29, 2024
4791576
fixing tests
maxi-cit Jan 29, 2024
6d8088a
add in-place update support
maxi-cit Jan 31, 2024
da29216
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Feb 2, 2024
2710873
fixed tests
maxi-cit Feb 8, 2024
8b3bf5c
fixed annotations
maxi-cit Feb 8, 2024
46920e4
validated clusters and node pools tests. Isolated node pool auto config
maxi-cit Feb 12, 2024
2d7a45d
Merge remote-tracking branch 'upstream/main' into add-resource-manage…
maxi-cit Feb 12, 2024
0ffc6b9
isolated resource manager tags from docs
maxi-cit Feb 12, 2024
3f31e7a
fixed permission issue
maxi-cit Feb 14, 2024
0a5cc41
fixed spaces
maxi-cit Feb 14, 2024
06f11a7
fixed non determinism on tag keys
maxi-cit Feb 15, 2024
10bc6be
removed auto_pilot rmts
maxi-cit Feb 19, 2024
9fc074b
fixed time_sleep
maxi-cit Feb 19, 2024
074ad81
sync merge from upstream/main
maxi-cit Feb 19, 2024
b863ab3
add depends_on to IAM policies
maxi-cit Feb 21, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ func ResourceComputeInstance() *schema.Resource {
},
},

"params": {
maxi-cit marked this conversation as resolved.
Show resolved Hide resolved
"params": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Expand All @@ -673,7 +673,7 @@ func ResourceComputeInstance() *schema.Resource {
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `A set of key/value label pairs assigned to the instance.

**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
Please refer to the field 'effective_labels' for all of the labels present on the resource.`,
},
Expand Down Expand Up @@ -1422,7 +1422,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
return fmt.Errorf("Error creating instance while setting the security policies: %s", err)
}
<% end -%>

err = waitUntilInstanceHasDesiredStatus(config, d)
if err != nil {
return fmt.Errorf("Error waiting for status: %s", err)
Expand Down Expand Up @@ -1936,7 +1936,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
return fmt.Errorf("Instance had unexpected number of network interfaces: %d", len(instance.NetworkInterfaces))
}

<% unless version == 'ga' -%>
<% unless version == 'ga' -%>
updateSecurityPolicy := false
for i := 0; i < len(instance.NetworkInterfaces); i++ {
prefix := fmt.Sprintf("network_interface.%d", i)
Expand Down
40 changes: 38 additions & 2 deletions mmv1/third_party/terraform/services/container/node_config.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,11 @@ func schemaNodeConfig() *schema.Schema {
},
},
},
"resource_manager_tags": {
maxi-cit marked this conversation as resolved.
Show resolved Hide resolved
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.`,
maxi-cit marked this conversation as resolved.
Show resolved Hide resolved
},
<% unless version == 'ga' -%>
"enable_confidential_storage": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -884,6 +889,10 @@ func expandNodeConfig(v interface{}) *container.NodeConfig {
nc.ResourceLabels = m
}

if v, ok := nodeConfig["resource_manager_tags"]; ok && len(v.(map[string]interface{})) > 0 {
nc.ResourceManagerTags = expandResourceManagerTags(v)
maxi-cit marked this conversation as resolved.
Show resolved Hide resolved
}

if v, ok := nodeConfig["tags"]; ok {
tagsList := v.([]interface{})
tags := []string{}
Expand Down Expand Up @@ -974,7 +983,7 @@ func expandNodeConfig(v interface{}) *container.NodeConfig {
nc.EnableConfidentialStorage = v.(bool)
}
<% end -%>

<% unless version == "ga" -%>
if v, ok := nodeConfig["host_maintenance_policy"]; ok {
nc.HostMaintenancePolicy = expandHostMaintenancePolicy(v)
Expand All @@ -988,6 +997,19 @@ func expandNodeConfig(v interface{}) *container.NodeConfig {
return nc
}

func expandResourceManagerTags(v interface{}) *container.ResourceManagerTags {
rmts := make(map[string]string)

if v != nil {
rmts = tpgresource.ConvertStringMap(v.(map[string]interface{}))
}

return &container.ResourceManagerTags{
Tags: rmts,
ForceSendFields: []string{"Tags"},
}
}

func expandWorkloadMetadataConfig(v interface{}) *container.WorkloadMetadataConfig {
if v == nil {
return nil
Expand Down Expand Up @@ -1213,7 +1235,8 @@ func flattenNodeConfig(c *container.NodeConfig, v interface{}) []map[string]inte
"advanced_machine_features": flattenAdvancedMachineFeaturesConfig(c.AdvancedMachineFeatures),
"sole_tenant_config": flattenSoleTenantConfig(c.SoleTenantConfig),
"fast_socket": flattenFastSocket(c.FastSocket),
<% unless version == 'ga' -%>
"resource_manager_tags": flattenResourceManagerTags(c.ResourceManagerTags),
<% unless version == 'ga' -%>
"enable_confidential_storage": c.EnableConfidentialStorage,
<% end -%>
})
Expand All @@ -1225,6 +1248,19 @@ func flattenNodeConfig(c *container.NodeConfig, v interface{}) []map[string]inte
return config
}

func flattenResourceManagerTags(c *container.ResourceManagerTags) map[string]interface{} {
rmt := make(map[string]interface{})

if c != nil {
for k, v := range c.Tags {
rmt[k] = v
}

}

return rmt
}

func flattenAdvancedMachineFeaturesConfig(c *container.AdvancedMachineFeatures) []map[string]interface{} {
result := []map[string]interface{}{}
if c != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ var (
forceNewClusterNodeConfigFields = []string{
"labels",
"workload_metadata_config",
"resource_manager_tags",
}

suppressDiffForAutopilot = schema.SchemaDiffSuppressFunc(func(k, oldValue, newValue string, d *schema.ResourceData) bool {
Expand Down Expand Up @@ -1424,11 +1425,11 @@ func ResourceContainerCluster() *schema.Resource {
"node_pool_defaults": clusterSchemaNodePoolDefaults(),

"node_pool_auto_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `Node pool configs that apply to all auto-provisioned node pools in autopilot clusters and node auto-provisioning enabled clusters.`,
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `Node pool configs that apply to all auto-provisioned node pools in autopilot clusters and node auto-provisioning enabled clusters.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"network_tags": {
Expand Down Expand Up @@ -5266,7 +5267,7 @@ func expandFleet(configured interface{}) *container.Fleet {
return &container.Fleet{
Project: config["project"].(string),
}
}
}

func expandEnableK8sBetaApis(configured interface{}, enabledAPIs []string) *container.K8sBetaAPIConfig {
l := configured.([]interface{})
Expand Down Expand Up @@ -5424,6 +5425,7 @@ func expandNodePoolAutoConfig(configured interface{}) *container.NodePoolAutoCon
if v, ok := config["network_tags"]; ok && len(v.([]interface{})) > 0 {
npac.NetworkTags = expandNodePoolAutoConfigNetworkTags(v)
}

return npac
}

Expand Down Expand Up @@ -6129,7 +6131,7 @@ func flattenFleet(c *container.Fleet) []map[string]interface{} {
membership_id = match[4]
membership_location = match[3]
}

return []map[string]interface{}{
{
"project": c.Project,
Expand Down
Loading
Loading