Skip to content

Commit

Permalink
Add check on import name split length. Prevent panic if only short na…
Browse files Browse the repository at this point in the history
…me is supplied
  • Loading branch information
slevenick committed Jul 17, 2019
1 parent bf83cf4 commit bca1cbe
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
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}}/<%= object.name.underscore -%>/{{short_name}}")
}
d.Set("parent", fmt.Sprintf("%s/%s", stringParts[0], stringParts[1]))
return []*schema.ResourceData{d}, nil

0 comments on commit bca1cbe

Please sign in to comment.