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.
write a new custom import that can extract taxonomy and name both. (G…
…oogleCloudPlatform#4262) * write a new custom import that can extract taxonomy and name both. * move custom import to subfolder. * update because project and location are set in the parent actually
- Loading branch information
1 parent
a1eff96
commit 70e2ea3
Showing
2 changed files
with
18 additions
and
2 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
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,16 @@ | ||
config := meta.(*Config) | ||
|
||
if err := parseImportId([]string{ | ||
"(?P<taxonomy>projects/[^/]+/locations/[^/]+/taxonomies/[^/]+)/policyTags/(?P<name>.+)"}, d, config); err != nil { | ||
return nil, err | ||
} | ||
|
||
originalName := d.Get("name").(string) | ||
originalTaxonomy := d.Get("taxonomy").(string) | ||
name := fmt.Sprintf("%s/policyTags/%s", originalTaxonomy, originalName) | ||
|
||
if err := d.Set("name", name); err != nil { | ||
return nil, fmt.Errorf("Error setting name: %s", err) | ||
} | ||
d.SetId(name) | ||
return []*schema.ResourceData{d}, nil |