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

Backfill terraform_labels with state upgrader for the immutable MMv1 resources #9438

Merged
merged 1 commit into from
Nov 13, 2023
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
2 changes: 2 additions & 0 deletions mmv1/products/beyondcorp/AppGateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ self_link: projects/{{project}}/locations/{{region}}/appGateways/{{name}}
create_url: projects/{{project}}/locations/{{region}}/appGateways?app_gateway_id={{name}}
# This resources is not updatable
immutable: true
schema_version: 1
state_upgraders: true
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
Expand Down
2 changes: 2 additions & 0 deletions mmv1/products/bigquery/Job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ kind: 'bigquery#job'
base_url: projects/{{project}}/jobs
self_link: projects/{{project}}/jobs/{{job_id}}?location={{location}}
immutable: true
schema_version: 1
state_upgraders: true
description: |
Jobs are actions that BigQuery runs on your behalf to load data, export data, query data, or copy data.
Once a BigQuery job is created, it cannot be changed or deleted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ references: !ruby/object:Api::Resource::ReferenceLinks
'Manage certificate issuance configs': 'https://cloud.google.com/certificate-manager/docs/issuance-configs'
api: 'https://cloud.google.com/certificate-manager/docs/reference/certificate-manager/rest/v1/projects.locations.certificateIssuanceConfigs'
immutable: true
schema_version: 1
state_upgraders: true
description: |
Certificate represents a HTTP-reachable backend for a Certificate.
async: !ruby/object:Api::OpAsync
Expand Down
2 changes: 2 additions & 0 deletions mmv1/products/datastream/PrivateConnection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ references: !ruby/object:Api::Resource::ReferenceLinks
description: |
The PrivateConnection resource is used to establish private connectivity between Datastream and a customer's network.
immutable: true
schema_version: 1
state_upgraders: true
id_format: projects/{{project}}/locations/{{location}}/privateConnections/{{private_connection_id}}
import_format:
[
Expand Down
2 changes: 2 additions & 0 deletions mmv1/products/mlengine/Model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ base_url: projects/{{project}}/models
self_link: projects/{{project}}/models/{{name}}
# This resources is not updatable (outside of versions, which is a version-level method)
immutable: true
schema_version: 1
state_upgraders: true
async: !ruby/object:Api::OpAsync
actions: ['delete']
operation: !ruby/object:Api::OpAsync::Operation
Expand Down
2 changes: 2 additions & 0 deletions mmv1/products/networkservices/ServiceBinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ description: |
ServiceBinding is the resource that defines a Service Directory Service to be used in a
BackendService resource.
immutable: true
schema_version: 1
state_upgraders: true
references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/traffic-director/docs/reference/network-services/rest/v1beta1/projects.locations.serviceBindings'
async: !ruby/object:Api::OpAsync
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
func resourceBeyondcorpAppGatewayResourceV0() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `ID of the AppGateway.`,
},
"display_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `An arbitrary user-provided name for the AppGateway.`,
},
"host_type": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: verify.ValidateEnum([]string{"HOST_TYPE_UNSPECIFIED", "GCP_REGIONAL_MIG", ""}),
Description: `The type of hosting used by the AppGateway. Default value: "HOST_TYPE_UNSPECIFIED" Possible values: ["HOST_TYPE_UNSPECIFIED", "GCP_REGIONAL_MIG"]`,
Default: "HOST_TYPE_UNSPECIFIED",
},
"labels": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Description: `Resource labels to represent user provided metadata.


**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.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"region": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `The region of the AppGateway.`,
},
"type": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: verify.ValidateEnum([]string{"TYPE_UNSPECIFIED", "TCP_PROXY", ""}),
Description: `The type of network connectivity used by the AppGateway. Default value: "TYPE_UNSPECIFIED" Possible values: ["TYPE_UNSPECIFIED", "TCP_PROXY"]`,
Default: "TYPE_UNSPECIFIED",
},
"allocated_connections": {
Type: schema.TypeList,
Computed: true,
Description: `A list of connections allocated for the Gateway.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ingress_port": {
Type: schema.TypeInt,
Optional: true,
Description: `The ingress port of an allocated connection.`,
},
"psc_uri": {
Type: schema.TypeString,
Optional: true,
Description: `The PSC uri of an allocated connection.`,
},
},
},
},
"effective_labels": {
Type: schema.TypeMap,
Computed: true,
ForceNew: true,
Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"state": {
Type: schema.TypeString,
Computed: true,
Description: `Represents the different states of a AppGateway.`,
},
"terraform_labels": {
Type: schema.TypeMap,
Computed: true,
ForceNew: true,
Description: `The combination of labels configured directly on the resource
and default labels configured on the provider.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"uri": {
Type: schema.TypeString,
Computed: true,
Description: `Server-defined URI for this resource.`,
},
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
UseJSONNumber: true,
}
}

func ResourceBeyondcorpAppGatewayUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
return tpgresource.TerraformLabelsStateUpgrade(rawState)
}
Loading