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

Convert old import formats (using non-/) to use /. #2638

Merged
merged 2 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func resourceFolderOrgPolicyImporter(d *schema.ResourceData, meta interface{}) (
config := meta.(*Config)

if err := parseImportId([]string{
"folders/(?P<folder>[^/]+):constraints/(?P<constraint>[^/]+)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need similar changes for the datasources?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

"(?P<folder>[^/]+):(?P<constraint>[^/]+)"},
"folders/(?P<folder>[^/]+)/constraints/(?P<constraint>[^/]+)",
"(?P<folder>[^/]+)/(?P<constraint>[^/]+)"},
d, config); err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(), ":")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this cause issues with our import tests if we don't update the id that is set in this resource?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - fixed. Having trouble running the tests since they don't work at the moment due to other 3.0.0 changes.

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])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Original file line number Diff line number Diff line change
Expand Up @@ -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.