forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix import of bigquery transfer config location (GoogleCloudPlatform#…
…8768) * Fix import of bigquery transfer config location * Fix import of bigquery transfer config when name does not contain location * Fix indentation in bigquery_data_transfer_self_link_as_name_set_location.go.erb
- Loading branch information
1 parent
097a65b
commit 32971ff
Showing
2 changed files
with
25 additions
and
3 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
21 changes: 21 additions & 0 deletions
21
...ates/terraform/custom_import/bigquery_data_transfer_self_link_as_name_set_location.go.erb
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,21 @@ | ||
|
||
config := meta.(*transport_tpg.Config) | ||
|
||
// current import_formats can't import fields with forward slashes in their value | ||
if err := tpgresource.ParseImportId([]string{"(?P<project>[^ ]+) (?P<name>[^ ]+)", "(?P<name>[^ ]+)"}, d, config); err != nil { | ||
return nil, err | ||
} | ||
|
||
// import location if the name format follows: projects/{{project}}/locations/{{location}}/transferConfigs/{{config_id}} | ||
name := d.Get("name").(string) | ||
stringParts := strings.Split(name, "/") | ||
if len(stringParts) == 6 { | ||
if err := d.Set("location", stringParts[3]); err != nil { | ||
return nil, fmt.Errorf("Error setting location: %s", err) | ||
} | ||
} else { | ||
log.Printf("[INFO] Transfer config location not imported as it is not included in the name: %s", name) | ||
} | ||
|
||
|
||
return []*schema.ResourceData{d}, nil |