-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add location field to google_network_services_mesh (#12991)
- Loading branch information
Showing
3 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
mmv1/templates/terraform/examples/network_services_mesh_location.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "google_network_services_mesh" "{{$.PrimaryResourceId}}" { | ||
provider = google-beta | ||
name = "{{index $.Vars "resource_name"}}" | ||
location = "global" | ||
} |
98 changes: 98 additions & 0 deletions
98
mmv1/templates/terraform/state_migrations/network_services_mesh.go.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
func resourceNetworkServicesMeshResourceV0() *schema.Resource { | ||
return &schema.Resource{ | ||
Create: resourceNetworkServicesMeshCreate, | ||
Read: resourceNetworkServicesMeshRead, | ||
Update: resourceNetworkServicesMeshUpdate, | ||
Delete: resourceNetworkServicesMeshDelete, | ||
|
||
Importer: &schema.ResourceImporter{ | ||
State: resourceNetworkServicesMeshImport, | ||
}, | ||
|
||
Timeouts: &schema.ResourceTimeout{ | ||
Create: schema.DefaultTimeout(30 * time.Minute), | ||
Update: schema.DefaultTimeout(30 * time.Minute), | ||
Delete: schema.DefaultTimeout(30 * time.Minute), | ||
}, | ||
|
||
CustomizeDiff: customdiff.All( | ||
tpgresource.SetLabelsDiff, | ||
tpgresource.DefaultProviderProject, | ||
), | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: `Short name of the Mesh resource to be created.`, | ||
}, | ||
"description": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: `A free-text description of the resource. Max length 1024 characters.`, | ||
}, | ||
"interception_port": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Description: `Optional. If set to a valid TCP port (1-65535), instructs the SIDECAR proxy to listen on the | ||
specified port of localhost (127.0.0.1) address. The SIDECAR proxy will expect all traffic to | ||
be redirected to this port regardless of its actual ip:port destination. If unset, a port | ||
'15001' is used as the interception port. This will is applicable only for sidecar proxy | ||
deployments.`, | ||
}, | ||
"labels": { | ||
Type: schema.TypeMap, | ||
Optional: true, | ||
Description: `Set of label tags associated with the Mesh resource. | ||
|
||
**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}, | ||
}, | ||
"create_time": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: `Time the Mesh was created in UTC.`, | ||
}, | ||
"effective_labels": { | ||
Type: schema.TypeMap, | ||
Computed: 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}, | ||
}, | ||
"self_link": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: `Server-defined URL of this resource.`, | ||
}, | ||
"terraform_labels": { | ||
Type: schema.TypeMap, | ||
Computed: true, | ||
Description: `The combination of labels configured directly on the resource | ||
and default labels configured on the provider.`, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
"update_time": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: `Time the Mesh was updated in UTC.`, | ||
}, | ||
"project": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
ForceNew: true, | ||
}, | ||
}, | ||
UseJSONNumber: true, | ||
} | ||
} | ||
|
||
func ResourceNetworkServicesMeshUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error){ | ||
log.Printf("[DEBUG] Attributes before migration: %#v", rawState) | ||
if _, ok := rawState["location"]; !ok { | ||
rawState["location"] = "global" | ||
} | ||
log.Printf("[DEBUG] Attributes after migration: %#v", rawState) | ||
return rawState, nil | ||
} |