Skip to content

Commit

Permalink
Add check on import name split length
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
slevenick authored and modular-magician committed Jul 17, 2019
1 parent 6b467e3 commit d3541c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions google-beta/resource_access_context_manager_access_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ func resourceAccessContextManagerAccessLevelImport(d *schema.ResourceData, meta
return nil, err
}
stringParts := strings.Split(d.Get("name").(string), "/")
if len(stringParts) < 2 {
return nil, fmt.Errorf("Error parsing parent name. Should be in form accessPolicies/{{policy_id}}/accessLevels/{{short_name}}")
}
d.Set("parent", fmt.Sprintf("%s/%s", stringParts[0], stringParts[1]))
return []*schema.ResourceData{d}, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ func resourceAccessContextManagerServicePerimeterImport(d *schema.ResourceData,
return nil, err
}
stringParts := strings.Split(d.Get("name").(string), "/")
if len(stringParts) < 2 {
return nil, fmt.Errorf("Error parsing parent name. Should be in form accessPolicies/{{policy_id}}/servicePerimeters/{{short_name}}")
}
d.Set("parent", fmt.Sprintf("%s/%s", stringParts[0], stringParts[1]))
return []*schema.ResourceData{d}, nil
}
Expand Down

0 comments on commit d3541c9

Please sign in to comment.