Skip to content

Commit

Permalink
clean up temporary terraform files
Browse files Browse the repository at this point in the history
  • Loading branch information
djelusic committed Aug 27, 2021
1 parent 574faf0 commit 3c04f55
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (h *Deploy) Deploy(ctx context.Context, req *DeployRequest) (*DeployRespons
if err != nil {
return nil, err
}
defer tf.Cleanup()
d, err := deploy.New(p, req.Updates, tf)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions api/destroy/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (f *Destroy) Destroy(ctx context.Context, req *DestroyRequest) (*DestroyRes
if err != nil {
return nil, err
}
defer tf.Cleanup()
err = destroy.Destroy(p, tf)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions api/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (f *Setup) Setup(ctx context.Context, req *SetupRequest) (*SetupResponse, e
if err != nil {
return nil, err
}
defer tf.Cleanup()
apiGatewayUrl, err := setup.Setup(tf, req.Destroy)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions internal/assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions internal/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,9 @@ func (t *Terraform) apply(destroy bool) error {
}
return nil
}

func (t *Terraform) Cleanup() {
if err := os.RemoveAll(t.path); err != nil {
log.Error(err)
}
}

0 comments on commit 3c04f55

Please sign in to comment.