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 6f825f6 commit 1bcf781
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions google/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
3 changes: 3 additions & 0 deletions google/resource_access_context_manager_service_perimeter.go
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 1bcf781

Please sign in to comment.