Skip to content

Commit 4a979d8

Browse files
committed
Apply new annotations model to more resources
1 parent df9725a commit 4a979d8

17 files changed

+42
-45
lines changed

mmv1/products/cloudrunv2/Job.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ properties:
137137
138138
Cloud Run API v2 does not support labels with `run.googleapis.com`, `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` namespaces, and they will be rejected.
139139
All system labels in v1 now have a corresponding field in v2 Job.
140-
- !ruby/object:Api::Type::KeyValuePairs
140+
- !ruby/object:Api::Type::KeyValueAnnotations
141141
name: "annotations"
142142
description: |-
143143
Unstructured key value map that may be set by external tools to store and arbitrary metadata. They are not queryable and should be preserved when modifying objects.

mmv1/products/gkeonprem/BareMetalAdminCluster.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ properties:
133133
Allows clients to perform consistent read-modify-writes
134134
through optimistic concurrency control.
135135
output: true
136-
- !ruby/object:Api::Type::KeyValuePairs
136+
- !ruby/object:Api::Type::KeyValueAnnotations
137137
name: "annotations"
138138
description: |
139139
Annotations on the Bare Metal Admin Cluster.

mmv1/products/gkeonprem/BareMetalCluster.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ properties:
8585
required: true
8686
description: |
8787
A human readable description of this Bare Metal User Cluster.
88-
- !ruby/object:Api::Type::KeyValuePairs
88+
- !ruby/object:Api::Type::KeyValueAnnotations
8989
name: "annotations"
9090
description: |
9191
Annotations on the Bare Metal User Cluster.
@@ -96,7 +96,6 @@ properties:
9696
Prefix must be a DNS subdomain.
9797
Name must be 63 characters or less, begin and end with alphanumerics,
9898
with dashes (-), underscores (_), dots (.), and alphanumerics between.
99-
default_from_api: true
10099
- !ruby/object:Api::Type::NestedObject
101100
name: "networkConfig"
102101
description: |

mmv1/products/gkeonprem/BareMetalNodePool.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ properties:
7474
name: 'displayName'
7575
description: |
7676
The display name for the Bare Metal Node Pool.
77-
- !ruby/object:Api::Type::KeyValuePairs
77+
- !ruby/object:Api::Type::KeyValueAnnotations
7878
name: 'annotations'
7979
description: |
8080
Annotations on the Bare Metal Node Pool.
@@ -85,7 +85,6 @@ properties:
8585
Prefix must be a DNS subdomain.
8686
Name must be 63 characters or less, begin and end with alphanumerics,
8787
with dashes (-), underscores (_), dots (.), and alphanumerics between.
88-
default_from_api: true
8988
- !ruby/object:Api::Type::NestedObject
9089
name: 'nodePoolConfig'
9190
required: true

mmv1/products/gkeonprem/VmwareCluster.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ properties:
8989
required: true
9090
description: |
9191
The Anthos clusters on the VMware version for your user cluster.
92-
- !ruby/object:Api::Type::KeyValuePairs
92+
- !ruby/object:Api::Type::KeyValueAnnotations
9393
name: 'annotations'
9494
description: |
9595
Annotations on the VMware User Cluster.
@@ -100,7 +100,6 @@ properties:
100100
Prefix must be a DNS subdomain.
101101
Name must be 63 characters or less, begin and end with alphanumerics,
102102
with dashes (-), underscores (_), dots (.), and alphanumerics between.
103-
default_from_api: true
104103
- !ruby/object:Api::Type::NestedObject
105104
name: 'controlPlaneNode'
106105
description: |

mmv1/products/gkeonprem/VmwareNodePool.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ properties:
7171
- !ruby/object:Api::Type::String
7272
name: "displayName"
7373
description: The display name for the node pool.
74-
- !ruby/object:Api::Type::KeyValuePairs
74+
- !ruby/object:Api::Type::KeyValueAnnotations
7575
name: "annotations"
7676
description: |
7777
Annotations on the node Pool.
@@ -82,7 +82,6 @@ properties:
8282
Prefix must be a DNS subdomain.
8383
Name must be 63 characters or less, begin and end with alphanumerics,
8484
with dashes (-), underscores (_), dots (.), and alphanumerics between.
85-
default_from_api: true
8685
- !ruby/object:Api::Type::NestedObject
8786
name: "nodePoolAutoscaling"
8887
description: Node Pool autoscaling config for the node pool.

mmv1/products/secretmanager/Secret.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ properties:
7676
7777
An object containing a list of "key": value pairs. Example:
7878
{ "name": "wrench", "mass": "1.3kg", "count": "3" }.
79-
- !ruby/object:Api::Type::KeyValuePairs
79+
- !ruby/object:Api::Type::KeyValueAnnotations
8080
name: annotations
8181
description: |
8282
Custom metadata about the secret.

mmv1/products/workstations/Workstation.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ properties:
122122
description:
123123
'Client-specified labels that are applied to the resource and that are
124124
also propagated to the underlying Compute Engine resources.'
125-
- !ruby/object:Api::Type::KeyValuePairs
125+
- !ruby/object:Api::Type::KeyValueAnnotations
126126
name: 'annotations'
127127
description: 'Client-specified annotations. This is distinct from labels.'
128128
- !ruby/object:Api::Type::Time

mmv1/products/workstations/WorkstationCluster.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ properties:
118118
Whether this resource is in degraded mode, in which case it may require user action to restore full functionality.
119119
Details can be found in the conditions field.
120120
output: true
121-
- !ruby/object:Api::Type::KeyValuePairs
121+
- !ruby/object:Api::Type::KeyValueAnnotations
122122
name: "annotations"
123123
description: "Client-specified annotations. This is distinct from labels."
124124
- !ruby/object:Api::Type::Fingerprint

mmv1/products/workstations/WorkstationConfig.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ properties:
158158
description:
159159
'Client-specified labels that are applied to the resource and that are
160160
also propagated to the underlying Compute Engine resources.'
161-
- !ruby/object:Api::Type::KeyValuePairs
161+
- !ruby/object:Api::Type::KeyValueAnnotations
162162
name: 'annotations'
163163
description: 'Client-specified annotations. This is distinct from labels.'
164164
- !ruby/object:Api::Type::Fingerprint

mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobFullUpdate(t *testing.T) {
2626
ResourceName: "google_cloud_run_v2_job.default",
2727
ImportState: true,
2828
ImportStateVerify: true,
29-
ImportStateVerifyIgnore: []string{"location", "launch_stage"},
29+
ImportStateVerifyIgnore: []string{"location", "launch_stage", "annotations"},
3030
},
3131
{
3232
Config: testAccCloudRunV2Job_cloudrunv2JobFullUpdate(context),
@@ -35,7 +35,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobFullUpdate(t *testing.T) {
3535
ResourceName: "google_cloud_run_v2_job.default",
3636
ImportState: true,
3737
ImportStateVerify: true,
38-
ImportStateVerifyIgnore: []string{"location", "launch_stage"},
38+
ImportStateVerifyIgnore: []string{"location", "launch_stage", "annotations"},
3939
},
4040
},
4141
})

mmv1/third_party/terraform/services/gkeonprem/resource_gkeonprem_bare_metal_cluster_test.go.erb

+6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func testAccGkeonpremBareMetalCluster_bareMetalClusterUpdateMetalLbStart(context
105105
provider = google-beta
106106
name = "cluster-metallb"
107107
location = "us-west1"
108+
annotations = {
109+
env = "test"
110+
}
108111
admin_cluster_membership = "projects/870316890899/locations/global/memberships/gkeonprem-terraform-test"
109112
bare_metal_version = "1.12.3"
110113
network_config {
@@ -181,6 +184,9 @@ func testAccGkeonpremBareMetalCluster_bareMetalClusterUpdateMetalLb(context map[
181184
provider = google-beta
182185
name = "cluster-metallb"
183186
location = "us-west1"
187+
annotations = {
188+
env = "test-update"
189+
}
184190
admin_cluster_membership = "projects/870316890899/locations/global/memberships/gkeonprem-terraform-test"
185191
bare_metal_version = "1.12.3"
186192
network_config {

mmv1/third_party/terraform/services/secretmanager/resource_secret_manager_secret_test.go.erb

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestAccSecretManagerSecret_annotationsUpdate(t *testing.T) {
8383
ResourceName: "google_secret_manager_secret.secret-with-annotations",
8484
ImportState: true,
8585
ImportStateVerify: true,
86-
ImportStateVerifyIgnore: []string{"ttl"},
86+
ImportStateVerifyIgnore: []string{"ttl", "labels", "terraform_labels", "annotations"},
8787
},
8888
{
8989
Config: testAccSecretManagerSecret_annotationsUpdate(context),
@@ -92,7 +92,7 @@ func TestAccSecretManagerSecret_annotationsUpdate(t *testing.T) {
9292
ResourceName: "google_secret_manager_secret.secret-with-annotations",
9393
ImportState: true,
9494
ImportStateVerify: true,
95-
ImportStateVerifyIgnore: []string{"ttl"},
95+
ImportStateVerifyIgnore: []string{"ttl", "labels", "terraform_labels", "annotations"},
9696
},
9797
{
9898
Config: testAccSecretManagerSecret_annotationsBasic(context),
@@ -101,7 +101,7 @@ func TestAccSecretManagerSecret_annotationsUpdate(t *testing.T) {
101101
ResourceName: "google_secret_manager_secret.secret-with-annotations",
102102
ImportState: true,
103103
ImportStateVerify: true,
104-
ImportStateVerifyIgnore: []string{"ttl"},
104+
ImportStateVerifyIgnore: []string{"ttl", "labels", "terraform_labels", "annotations"},
105105
},
106106
},
107107
})

mmv1/third_party/terraform/services/workstations/resource_workstations_workstation_cluster_test.go.erb

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestAccWorkstationsWorkstationCluster_update(t *testing.T) {
2828
ResourceName: "google_workstations_workstation_cluster.default",
2929
ImportState: true,
3030
ImportStateVerify: true,
31-
ImportStateVerifyIgnore: []string{"etag"},
31+
ImportStateVerifyIgnore: []string{"etag", "annotations"},
3232
},
3333
{
3434
Config: testAccWorkstationsWorkstationCluster_update(context),
@@ -37,7 +37,7 @@ func TestAccWorkstationsWorkstationCluster_update(t *testing.T) {
3737
ResourceName: "google_workstations_workstation_cluster.default",
3838
ImportState: true,
3939
ImportStateVerify: true,
40-
ImportStateVerifyIgnore: []string{"etag"},
40+
ImportStateVerifyIgnore: []string{"etag", "annotations"},
4141
},
4242
},
4343
})
@@ -62,7 +62,7 @@ func TestAccWorkstationsWorkstationCluster_Private_update(t *testing.T) {
6262
ResourceName: "google_workstations_workstation_cluster.default",
6363
ImportState: true,
6464
ImportStateVerify: true,
65-
ImportStateVerifyIgnore: []string{"etag"},
65+
ImportStateVerifyIgnore: []string{"etag", "annotations"},
6666
},
6767
{
6868
Config: testAccWorkstationsWorkstationCluster_private_update(context),
@@ -71,7 +71,7 @@ func TestAccWorkstationsWorkstationCluster_Private_update(t *testing.T) {
7171
ResourceName: "google_workstations_workstation_cluster.default",
7272
ImportState: true,
7373
ImportStateVerify: true,
74-
ImportStateVerifyIgnore: []string{"etag"},
74+
ImportStateVerifyIgnore: []string{"etag", "annotations"},
7575
},
7676
},
7777
})

mmv1/third_party/terraform/services/workstations/resource_workstations_workstation_config_test.go.erb

+3-3
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func TestAccWorkstationsWorkstationConfig_update(t *testing.T) {
242242
ResourceName: "google_workstations_workstation_cluster.default",
243243
ImportState: true,
244244
ImportStateVerify: true,
245-
ImportStateVerifyIgnore: []string{"etag"},
245+
ImportStateVerifyIgnore: []string{"etag", "annotations"},
246246
},
247247
{
248248
Config: testAccWorkstationsWorkstationConfig_update(context),
@@ -251,7 +251,7 @@ func TestAccWorkstationsWorkstationConfig_update(t *testing.T) {
251251
ResourceName: "google_workstations_workstation_cluster.default",
252252
ImportState: true,
253253
ImportStateVerify: true,
254-
ImportStateVerifyIgnore: []string{"etag"},
254+
ImportStateVerifyIgnore: []string{"etag", "annotations"},
255255
},
256256
{
257257
Config: testAccWorkstationsWorkstationConfig_workstationConfigBasicExample(context),
@@ -260,7 +260,7 @@ func TestAccWorkstationsWorkstationConfig_update(t *testing.T) {
260260
ResourceName: "google_workstations_workstation_cluster.default",
261261
ImportState: true,
262262
ImportStateVerify: true,
263-
ImportStateVerifyIgnore: []string{"etag"},
263+
ImportStateVerifyIgnore: []string{"etag", "annotations"},
264264
},
265265
},
266266
})

mmv1/third_party/terraform/tpgresource/labels.go

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ import (
88
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
99
)
1010

11+
func FlattenLabels(labels map[string]string, d *schema.ResourceData) map[string]interface{} {
12+
transformed := make(map[string]interface{})
13+
14+
if v, ok := d.GetOk("labels"); ok {
15+
if labels != nil {
16+
for k, _ := range v.(map[string]interface{}) {
17+
transformed[k] = labels[k]
18+
}
19+
}
20+
}
21+
22+
return transformed
23+
}
24+
1125
func SetLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error {
1226
config := meta.(*transport_tpg.Config)
1327

mmv1/third_party/terraform/tpgresource/lables.go

-19
This file was deleted.

0 commit comments

Comments
 (0)