Skip to content

Commit

Permalink
Fixed import data catalog taxonomy (#4493) (#2961)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Feb 16, 2021
1 parent 1250ea5 commit 2c941e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .changelog/4493.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
datacatalog: Fixed import issue for `google_data_catalog_taxonomy`
```
13 changes: 4 additions & 9 deletions google-beta/resource_data_catalog_taxonomy.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,19 +325,14 @@ func resourceDataCatalogTaxonomyDelete(d *schema.ResourceData, meta interface{})
func resourceDataCatalogTaxonomyImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
config := meta.(*Config)

if err := parseImportId([]string{
"(?P<taxonomy>projects/[^/]+/locations/[^/]+/taxonomies/[^/]+)/policyTags/(?P<name>.+)"}, d, config); err != nil {
// current import_formats can't import fields with forward slashes in their value
if err := parseImportId([]string{"(?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)
}
name := d.Get("name").(string)
d.SetId(name)

return []*schema.ResourceData{d}, nil
}

Expand Down

0 comments on commit 2c941e0

Please sign in to comment.