Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Redo the error login in deleteResource to prevent panic (#38)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Peek <[email protected]>
  • Loading branch information
markpeek authored Feb 20, 2018
1 parent 05d55eb commit d6ea956
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions vrealize/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,15 @@ func deleteResource(d *schema.ResourceData, meta interface{}) error {
//Set a delete machine template function call.
//Which will fetch and return the delete machine template from the given template
DestroyMachineTemplate, resourceTemplate, errDestroyAction := client.GetDestroyActionTemplate(templateResources)
if errDestroyAction.Error() == "resource is not created or not found" {
d.SetId("")
return fmt.Errorf("possibly resource got deleted outside terraform")
}
if errDestroyAction != nil {
if errDestroyAction.Error() == "resource is not created or not found" {
d.SetId("")
return fmt.Errorf("possibly resource got deleted outside terraform")
}

return fmt.Errorf("Destory Machine action template failed to load: %v", errDestroyAction)
}

//Set a destroy machine REST call
_, errDestroyMachine := client.DestroyMachine(DestroyMachineTemplate, resourceTemplate)
//Raise an exception if error got while deleting resource
Expand Down

0 comments on commit d6ea956

Please sign in to comment.