Handle error of deferred deletion

This commit is contained in:
Wilken Rivera 2020-08-12 11:30:15 -04:00
parent 5700f74c8c
commit 55812fe8a5
1 changed files with 6 additions and 5 deletions

View File

@ -55,7 +55,12 @@ func (s *StepDeployTemplate) Run(ctx context.Context, state multistep.StateBag)
}
func (s *StepDeployTemplate) Cleanup(state multistep.StateBag) {
defer s.deleteTemplate(context.Background(), state)
defer func() {
err := s.deleteTemplate(context.Background(), state)
if err != nil {
s.say(s.client.LastError.Error())
}
}()
//Only clean up if this was an existing resource group and the resource group
//is marked as created
@ -167,10 +172,6 @@ func (s *StepDeployTemplate) deleteTemplate(ctx context.Context, state multistep
err = f.WaitForCompletionRef(ctx, s.client.DeploymentsClient.Client)
}
if err != nil {
s.say(s.client.LastError.Error())
}
return err
}