Skip to content

Commit

Permalink
fix: Set current working directory in deploy command (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarojasm95 authored Nov 5, 2024
1 parent 1c5a298 commit 8a268f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 2 additions & 3 deletions aladdin/commands/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ def deploy(
)
sys.exit(1)

with clone_and_checkout(git_ref, repo) as tmpdirname:
with working_directory(tmpdirname):
helm_chart_path = ProjectConf().get_helm_chart_path(chart)
with clone_and_checkout(git_ref, repo, cwd=True):
helm_chart_path = ProjectConf().get_helm_chart_path(chart)

helm_args = [
f"--values=aladdin://{cluster_code}",
Expand Down
15 changes: 10 additions & 5 deletions aladdin/lib/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess
import tempfile
import sys
from contextlib import contextmanager, suppress
from contextlib import contextmanager, suppress, nullcontext

from aladdin.lib.utils import working_directory
from aladdin.config import load_git_configs, ALADDIN_DEV
Expand Down Expand Up @@ -96,7 +96,7 @@ def _get_hash_ls_remote(cls, ref, url):


@contextmanager
def clone_and_checkout(githash, repo_name=None, debug=ALADDIN_DEV):
def clone_and_checkout(githash, repo_name=None, debug=ALADDIN_DEV, cwd=False):
current_hash = None
current_repo = None
with suppress(subprocess.CalledProcessError):
Expand All @@ -110,11 +110,14 @@ def clone_and_checkout(githash, repo_name=None, debug=ALADDIN_DEV):
current_hash == githash and
(Git.clean_working_tree() or debug)
):
yield Git.get_base_directory()
dir = Git.get_base_directory()
context = working_directory(dir) if cwd else nullcontext()
with context:
yield dir
return

if not repo_name:
logging.error(f"No repo found or specified")
logging.error("No repo found or specified")
return sys.exit(1)

git_account = load_git_configs()["account"]
Expand All @@ -133,4 +136,6 @@ def clone_and_checkout(githash, repo_name=None, debug=ALADDIN_DEV):
f"Could not checkout to ref '{githash}' in repo {git_url}. Have you pushed it to remote?"
)
return sys.exit(1)
yield tmpdirname
context = working_directory(tmpdirname) if cwd else nullcontext()
with context:
yield tmpdirname
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aladdin"
version = "1.29.8.9"
version = "1.29.8.10"
description = ""
authors = ["Fivestars <[email protected]>"]
include = [
Expand Down

0 comments on commit 8a268f5

Please sign in to comment.