Skip to content

Commit

Permalink
Apply new labels model to more resources (part 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
zli82016 committed Sep 13, 2023
1 parent 186acac commit 9bf01e6
Show file tree
Hide file tree
Showing 50 changed files with 113 additions and 99 deletions.
18 changes: 7 additions & 11 deletions mmv1/api/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,7 @@ def add_labels_fields(props, parent, labels)
end

props << build_terraform_labels_field('labels', labels.field_min_version)
props << build_effective_labels_field(
'labels', labels.field_min_version, labels.update_verb, labels.update_url
)
props << build_effective_labels_field('labels', labels)
end

def add_annotations_fields(props, parent, annotations)
Expand All @@ -495,13 +493,10 @@ def add_annotations_fields(props, parent, annotations)
@custom_diff.append('tpgresource.SetMetadataAnnotationsDiff')
end

props << build_effective_labels_field(
'annotations', annotations.field_min_version,
annotations.update_verb, annotations.update_url
)
props << build_effective_labels_field('annotations', annotations)
end

def build_effective_labels_field(name, min_version, update_verb, update_url)
def build_effective_labels_field(name, labels)
description = "All of #{name} (key/value pairs)\
present on the resource in GCP, including the #{name} configured through Terraform,\
other clients and services."
Expand All @@ -511,9 +506,10 @@ def build_effective_labels_field(name, min_version, update_verb, update_url)
output: true,
api_name: name,
description:,
min_version:,
update_verb:,
update_url:
min_version: labels.field_min_version,
update_verb: labels.update_verb,
update_url: labels.update_url,
immutable: labels.immutable
)
end

Expand Down
3 changes: 2 additions & 1 deletion mmv1/api/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ class KeyValuePairs < Composite
attr_accessor :ignore_write

def initialize(name: nil, output: nil, api_name: nil, description: nil, min_version: nil,
ignore_write: nil, update_verb: nil, update_url: nil)
ignore_write: nil, update_verb: nil, update_url: nil, immutable: nil)
super()

@name = name
Expand All @@ -780,6 +780,7 @@ def initialize(name: nil, output: nil, api_name: nil, description: nil, min_vers
@ignore_write = ignore_write
@update_verb = update_verb
@update_url = update_url
@immutable = immutable
end

def validate
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/activedirectory/Domain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ properties:
description:
'The unique name of the domain using the format:
`projects/{project}/locations/global/domains/{domainName}`.'
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: 'Resource labels that can contain user-provided metadata'
- !ruby/object:Api::Type::Array
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/activedirectory/Peering.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ properties:
output: true
description: |
Unique name of the peering in this scope including projects and location using the form: projects/{projectId}/locations/global/peerings/{peeringId}.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: 'Resource labels that can contain user-provided metadata'
- !ruby/object:Api::Type::String
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/alloydb/Backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ properties:
required: true
immutable: true
diff_suppress_func: 'tpgresource.ProjectNumberDiffSuppress'
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: 'User-defined labels for the alloydb backup.'
- !ruby/object:Api::Type::Time
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/alloydb/Cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ properties:
output: true
description: |
The system-generated UID of the resource.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: 'User-defined labels for the alloydb cluster.'
- !ruby/object:Api::Type::NestedObject
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/apigateway/ApiConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ properties:
output: true
description: |
The ID of the associated Service Config (https://cloud.google.com/service-infrastructure/docs/glossary#config).
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
Resource labels to represent user-provided metadata.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/apigateway/ApiResource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ properties:
name: 'createTime'
description: Creation timestamp in RFC3339 text format.
output: true
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
Resource labels to represent user-provided metadata.
2 changes: 1 addition & 1 deletion mmv1/products/apigateway/Gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ properties:
description:
The default API Gateway host name of the form
{gatewayId}-{hash}.{region_code}.gateway.dev.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
Resource labels to represent user-provided metadata.
2 changes: 1 addition & 1 deletion mmv1/products/artifactregistry/Repository.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ properties:
name: description
description: |-
The user-provided description of the repository.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
Labels with user-defined metadata.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/beyondcorp/AppConnection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ properties:
name: 'displayName'
description: |
An arbitrary user-provided name for the AppConnection.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
Resource labels to represent user provided metadata.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/beyondcorp/AppConnector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ properties:
name: 'displayName'
description: |
An arbitrary user-provided name for the AppConnector.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
Resource labels to represent user provided metadata.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/beyondcorp/AppGateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ properties:
name: 'displayName'
description: |
An arbitrary user-provided name for the AppGateway.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
Resource labels to represent user provided metadata.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/bigquery/Job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ properties:
name: 'jobTimeoutMs'
description: |
Job timeout in milliseconds. If this time limit is exceeded, BigQuery may attempt to terminate the job.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
The labels associated with this job. You can use these to organize and group your jobs.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/bigquery/Table.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ properties:
name: 'id'
description: 'An opaque ID uniquely identifying the table.'
output: true
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
The labels associated with this dataset. You can use these to
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/certificatemanager/Certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ properties:
name: 'description'
description: |
A human-readable description of the resource.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: 'Set of label tags associated with the Certificate resource.'
- !ruby/object:Api::Type::String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ properties:
accurate to nanoseconds with up to nine fractional digits.
Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
output: true
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
'Set of label tags associated with the CertificateIssuanceConfig resource.
Expand Down
3 changes: 1 addition & 2 deletions mmv1/products/certificatemanager/CertificateMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ properties:
accurate to nanoseconds with up to nine fractional digits.
Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
output: true
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
Set of labels associated with a Certificate Map resource.
default_from_api: true
- !ruby/object:Api::Type::Array
name: 'gclbTargets'
description: |
Expand Down
3 changes: 1 addition & 2 deletions mmv1/products/certificatemanager/CertificateMapEntry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,12 @@ properties:
with nanosecond resolution and up to nine fractional digits.
Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
output: true
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
Set of labels associated with a Certificate Map Entry.
An object containing a list of "key": value pairs.
Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
default_from_api: true
- !ruby/object:Api::Type::Array
name: 'certificates'
required: true
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/certificatemanager/DnsAuthorization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ properties:
name: 'description'
description: |
A human-readable description of the resource.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description:
'Set of label tags associated with the DNS Authorization resource.'
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/certificatemanager/TrustConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ properties:
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
output: true
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: 'Set of label tags associated with the trust config.'
immutable: true
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/cloudfunctions/CloudFunction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ properties:
description: |
The version identifier of the Cloud Function. Each deployment attempt
results in a new version of a function being created.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
A set of key/value label pairs associated with this Cloud Function.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/cloudfunctions2/Function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ properties:
name: 'updateTime'
output: true
description: 'The last update timestamp of a Cloud Function.'
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
A set of key/value label pairs associated with this Cloud Function.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/cloudidentity/Group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ properties:
output: true
description: |
The time when the Group was last updated.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
required: true
description: |
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/cloudrunv2/Job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ properties:
output: true
description: |
A number that monotonically increases every time the user modifies the desired state.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |-
Unstructured key value map that can be used to organize and categorize objects. User-provided labels are shared with Google's billing system, so they can be used to filter, or break down billing charges by team, component,
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/cloudrunv2/Service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ properties:
output: true
description: |
A number that monotonically increases every time the user modifies the desired state. Please note that unlike v1, this is an int64 value. As with most Google APIs, its JSON representation will be a string instead of an integer.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |-
Unstructured key value map that can be used to organize and categorize objects. User-provided labels are shared with Google's billing system, so they can be used to filter, or break down billing charges by team, component,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ properties:
output: true
description: |
Output only. The timestamp when the resource was created. A timestamp in RFC3339 UTC 'Zulu' format, accurate to nanoseconds. Example: '2014-10-02T15:01:23.045123456Z'.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
The resource labels for connection profile to use to annotate any related underlying resources such as Compute Engine VMs.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/datafusion/Instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ properties:
name: 'enableRbac'
description: |
Option to enable granular role-based access control.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
The resource labels for instance to use to annotate any related underlying resources,
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/dataplex/Datascan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ properties:
name: 'displayName'
description: |
User friendly display name.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
User-defined labels for the scan. A list of key->value pairs.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/dataplex/Task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ properties:
- :CREATING
- :DELETING
- :ACTION_REQUIRED
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: |
User-defined labels for the task.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/datastream/ConnectionProfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ properties:
name: 'name'
output: true
description: The resource's name.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: Labels.
- !ruby/object:Api::Type::String
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/datastream/PrivateConnection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ properties:
name: 'name'
output: true
description: The resource's name.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: Labels.
- !ruby/object:Api::Type::String
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/datastream/Stream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ properties:
name: 'name'
output: true
description: The stream's name.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValueLabels
name: 'labels'
description: Labels.
- !ruby/object:Api::Type::String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ resource "google_certificate_manager_certificate" "<%= ctx[:primary_resource_id]
name = "<%= ctx[:vars]['cert_name'] %>"
description = "The default cert"
scope = "EDGE_CACHE"
labels = {
env = "test"
}
managed {
domains = [
google_certificate_manager_dns_authorization.instance.domain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAccActiveDirectoryDomain_update(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"domain_name"},
ImportStateVerifyIgnore: []string{"domain_name", "labels", "terraform_labels"},
},
{
Config: testAccADDomainUpdate(context),
Expand All @@ -48,7 +48,7 @@ func TestAccActiveDirectoryDomain_update(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"domain_name"},
ImportStateVerifyIgnore: []string{"domain_name", "labels", "terraform_labels"},
},
{
Config: testAccADDomainBasic(context),
Expand All @@ -57,7 +57,7 @@ func TestAccActiveDirectoryDomain_update(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"domain_name"},
ImportStateVerifyIgnore: []string{"domain_name", "labels", "terraform_labels"},
},
},
})
Expand Down
Loading

0 comments on commit 9bf01e6

Please sign in to comment.