From 272e41b4e12f7da8179c7e0f0bbced319f6093a7 Mon Sep 17 00:00:00 2001 From: Nathan McKinley Date: Tue, 12 Nov 2019 17:52:05 -0800 Subject: [PATCH] Convert old import formats (using non-/) to use /. (#2638) * Convert old import formats (using non-/) to use /. --- .../data_source_google_folder_organization_policy.go | 2 +- .../resources/resource_google_folder_organization_policy.go | 6 +++--- .../resources/resource_google_organization_policy.go | 6 +++--- .../terraform/website/docs/r/bigquery_table.html.markdown | 2 +- .../docs/r/google_folder_organization_policy.html.markdown | 4 ++-- .../website/docs/r/google_organization_policy.html.markdown | 5 ++++- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/third_party/terraform/data_sources/data_source_google_folder_organization_policy.go b/third_party/terraform/data_sources/data_source_google_folder_organization_policy.go index 5777ea75d268..b31f18c7687b 100644 --- a/third_party/terraform/data_sources/data_source_google_folder_organization_policy.go +++ b/third_party/terraform/data_sources/data_source_google_folder_organization_policy.go @@ -21,7 +21,7 @@ func dataSourceGoogleFolderOrganizationPolicy() *schema.Resource { func datasourceGoogleFolderOrganizationPolicyRead(d *schema.ResourceData, meta interface{}) error { - d.SetId(fmt.Sprintf("%s:%s", d.Get("folder"), d.Get("constraint"))) + d.SetId(fmt.Sprintf("%s/%s", d.Get("folder"), d.Get("constraint"))) return resourceGoogleFolderOrganizationPolicyRead(d, meta) } diff --git a/third_party/terraform/resources/resource_google_folder_organization_policy.go b/third_party/terraform/resources/resource_google_folder_organization_policy.go index 275c6dc12731..6bed8a291b24 100644 --- a/third_party/terraform/resources/resource_google_folder_organization_policy.go +++ b/third_party/terraform/resources/resource_google_folder_organization_policy.go @@ -43,8 +43,8 @@ func resourceFolderOrgPolicyImporter(d *schema.ResourceData, meta interface{}) ( config := meta.(*Config) if err := parseImportId([]string{ - "folders/(?P[^/]+):constraints/(?P[^/]+)", - "(?P[^/]+):(?P[^/]+)"}, + "folders/(?P[^/]+)/constraints/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)"}, d, config); err != nil { return nil, err } @@ -59,7 +59,7 @@ func resourceFolderOrgPolicyImporter(d *schema.ResourceData, meta interface{}) ( } func resourceGoogleFolderOrganizationPolicyCreate(d *schema.ResourceData, meta interface{}) error { - d.SetId(fmt.Sprintf("%s:%s", d.Get("folder"), d.Get("constraint"))) + d.SetId(fmt.Sprintf("%s/%s", d.Get("folder"), d.Get("constraint"))) if isOrganizationPolicyUnset(d) { return resourceGoogleFolderOrganizationPolicyDelete(d, meta) diff --git a/third_party/terraform/resources/resource_google_organization_policy.go b/third_party/terraform/resources/resource_google_organization_policy.go index 9e7535fad561..66a4c72ec324 100644 --- a/third_party/terraform/resources/resource_google_organization_policy.go +++ b/third_party/terraform/resources/resource_google_organization_policy.go @@ -155,7 +155,7 @@ func resourceGoogleOrganizationPolicy() *schema.Resource { } func resourceGoogleOrganizationPolicyCreate(d *schema.ResourceData, meta interface{}) error { - d.SetId(fmt.Sprintf("%s:%s", d.Get("org_id"), d.Get("constraint").(string))) + d.SetId(fmt.Sprintf("%s/%s", d.Get("org_id"), d.Get("constraint").(string))) if isOrganizationPolicyUnset(d) { return resourceGoogleOrganizationPolicyDelete(d, meta) @@ -224,9 +224,9 @@ func resourceGoogleOrganizationPolicyDelete(d *schema.ResourceData, meta interfa } func resourceGoogleOrganizationPolicyImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - parts := strings.Split(d.Id(), ":") + parts := strings.SplitN(d.Id(), "/", 2) if len(parts) != 2 { - return nil, fmt.Errorf("Invalid id format. Expecting {org_id}:{constraint}, got '%s' instead.", d.Id()) + return nil, fmt.Errorf("Invalid id format. Expecting {org_id}/{constraint}, got '%s' instead.", d.Id()) } d.Set("org_id", parts[0]) diff --git a/third_party/terraform/website/docs/r/bigquery_table.html.markdown b/third_party/terraform/website/docs/r/bigquery_table.html.markdown index 2e02807dfd67..be06f7fa42f4 100644 --- a/third_party/terraform/website/docs/r/bigquery_table.html.markdown +++ b/third_party/terraform/website/docs/r/bigquery_table.html.markdown @@ -244,5 +244,5 @@ exported: BigQuery tables can be imported using the `project`, `dataset_id`, and `table_id`, e.g. ``` -$ terraform import google_bigquery_table.default gcp-project:foo.bar +$ terraform import google_bigquery_table.default gcp-project/foo/bar ``` diff --git a/third_party/terraform/website/docs/r/google_folder_organization_policy.html.markdown b/third_party/terraform/website/docs/r/google_folder_organization_policy.html.markdown index 59d461c38ca6..7a4690f9d7eb 100644 --- a/third_party/terraform/website/docs/r/google_folder_organization_policy.html.markdown +++ b/third_party/terraform/website/docs/r/google_folder_organization_policy.html.markdown @@ -137,6 +137,6 @@ exported: Folder organization policies can be imported using any of the follow formats: ``` -$ terraform import google_folder_organization_policy.policy folders/folder-1234:constraints/serviceuser.services -$ terraform import google_folder_organization_policy.policy folder-1234:serviceuser.services +$ terraform import google_folder_organization_policy.policy folders/folder-1234/constraints/serviceuser.services +$ terraform import google_folder_organization_policy.policy folder-1234/serviceuser.services ``` diff --git a/third_party/terraform/website/docs/r/google_organization_policy.html.markdown b/third_party/terraform/website/docs/r/google_organization_policy.html.markdown index 5fa865badce8..784e3fc3cbf8 100644 --- a/third_party/terraform/website/docs/r/google_organization_policy.html.markdown +++ b/third_party/terraform/website/docs/r/google_organization_policy.html.markdown @@ -135,4 +135,7 @@ exported: Organization Policies can be imported using the `org_id` and the `constraint`, e.g. ``` -$ terraform import google_organization_policy.services_policy 123456789:constraints/serviceuser.services +$ terraform import google_organization_policy.services_policy 123456789/constraints/serviceuser.services +``` + +It is all right if the constraint contains a slash, as in the example above.