@@ -31,6 +31,10 @@ func (r *ResourceApp) DoRead(ctx context.Context, id string) (*apps.App, error)
3131}
3232
3333func (r * ResourceApp ) DoCreate (ctx context.Context , config * apps.App ) (string , * apps.App , error ) {
34+ if err := r .waitForDeletion (ctx , config .Name ); err != nil {
35+ return "" , nil , err
36+ }
37+
3438 request := apps.CreateAppRequest {
3539 App : * config ,
3640 NoCompute : true ,
@@ -63,10 +67,7 @@ func (r *ResourceApp) DoUpdate(ctx context.Context, id string, config *apps.App,
6367
6468func (r * ResourceApp ) DoDelete (ctx context.Context , id string ) error {
6569 _ , err := r .client .Apps .DeleteByName (ctx , id )
66- if err != nil {
67- return err
68- }
69- return r .waitForDeletion (ctx , id )
70+ return err
7071}
7172
7273func (* ResourceApp ) FieldTriggers (_ bool ) map [string ]deployplan.ActionType {
@@ -97,11 +98,9 @@ func (r *ResourceApp) waitForDeletion(ctx context.Context, name string) error {
9798 switch app .ComputeStatus .State {
9899 case apps .ComputeStateDeleting :
99100 return nil , retries .Continues ("app is deleting" )
100- case apps .ComputeStateActive , apps .ComputeStateStopped , apps .ComputeStateError :
101- err := fmt .Errorf ("app %s was not deleted, current state: %s" , name , app .ComputeStatus .State )
102- return nil , retries .Halt (err )
103101 default :
104- return nil , retries .Continues (fmt .Sprintf ("app is in %s state" , app .ComputeStatus .State ))
102+ err := fmt .Errorf ("app %s already exists" , name )
103+ return nil , retries .Halt (err )
105104 }
106105 })
107106 return err
0 commit comments