Skip to content

Commit

Permalink
Delete working directory after reconciliation - should help with #104
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivek Lakshmanan committed Dec 1, 2020
1 parent d6b7e8b commit 8bc2723
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/controller/stack/stack_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ func (r *ReconcileStack) Reconcile(request reconcile.Request) (reconcile.Result,
return reconcile.Result{}, err
}

// Delete the working directory after the reconciliation is completed (regardless of success or failure).
defer func() {
if sess.workdir != "" {
if err := os.RemoveAll(sess.workdir); err != nil {
sess.logger.Error(err, "Failed to delete working dir: %s", sess.workdir)
}
}
}()

// Step 2. If there are extra environment variables, read them in now and use them for subsequent commands.
err = sess.SetEnvs(stack.Envs, request.Namespace)
if err != nil {
Expand Down

0 comments on commit 8bc2723

Please sign in to comment.