Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PreserveWorkingDirectory flag #522

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Ignore existing workdir
  • Loading branch information
bacek committed Nov 13, 2023
commit 422bb6917f1192d11c86eccd98dd7f940ea18140
6 changes: 3 additions & 3 deletions pkg/controller/stack/stack_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ func (r *ReconcileStack) Reconcile(ctx context.Context, request reconcile.Reques

// Create the workspace directory. Any problem here is unexpected, and treated as a
// controller error.
_, err = sess.MakeWorkspaceDir()
_, err = sess.MakeWorkspaceDir(sess.stack.PreserveWorkingDirectory)
if err != nil {
return reconcile.Result{}, fmt.Errorf("unable to create tmp directory for workspace: %w", err)
}
Expand Down Expand Up @@ -1265,13 +1265,13 @@ func (sess *reconcileStackSession) getPulumiHome() string {
// stack is processed by at most one thread at a time, and stacks have unique qualified names, and
// the workspace directory is expected to be removed after processing, this won't cause collisions; but, we
// check anyway, treating the existence of the workspace directory as a crude lock.
func (sess *reconcileStackSession) MakeWorkspaceDir() (string, error) {
func (sess *reconcileStackSession) MakeWorkspaceDir(preserveWorkingDirectory bool) (string, error) {
workspaceDir := filepath.Join(sess.rootDir, "workspace")
_, err := os.Stat(workspaceDir)
switch {
case os.IsNotExist(err):
break
case err == nil:
case err == nil && !preserveWorkingDirectory:
return "", fmt.Errorf("expected workspace directory %q for stack not to exist already, but it does", workspaceDir)
case err != nil:
return "", fmt.Errorf("error while checking for workspace directory: %w", err)
Expand Down
Loading