Skip to content

Commit

Permalink
Fix aladdin config command when setting up aladdin (#120)
Browse files Browse the repository at this point in the history
- Fixed error in config command when setting up aladdin
  • Loading branch information
jarojasm95 authored Jan 24, 2022
1 parent 820997f commit 38a43a5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion aladdin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def load_config_from_file(file):


def load_config():
return load_config_from_file(f'{os.environ["ALADDIN_CONFIG_DIR"]}/config.json')
config_dir = os.getenv("ALADDIN_CONFIG_DIR")
return load_config_from_file(f"{config_dir}/config.json")


def load_user_config() -> dict:
Expand Down
6 changes: 5 additions & 1 deletion aladdin/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ def configure_env():
True if manage_software_dependencies is None else manage_software_dependencies
).lower()

aladdin_config = {}
with suppress(FileNotFoundError):
aladdin_config = config.load_config()

# Allow aladdin devs to use a custom aladdin image by setting ALADDIN_IMAGE
if not (os.getenv("ALADDIN_IMAGE") and config.ALADDIN_DEV):
# Set ALADDIN_IMAGE from the "aladdin.repo" config (or config.ALADDIN_DOCKER_REPO) and
# use the aladdin version as the image tag
os.environ["ALADDIN_IMAGE"] = "{}:{}".format(
search("aladdin.repo", config.load_config()) or config.ALADDIN_DOCKER_REPO,
search("aladdin.repo", aladdin_config) or config.ALADDIN_DOCKER_REPO,
__version__
)

Expand Down
5 changes: 4 additions & 1 deletion aladdin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ def cli():
cmd_args = list(filter(lambda arg: not arg.startswith("-"), sys.argv[1:]))
command = cmd_args[0] if cmd_args else None

if not env.set_config_path() and command != "config":
# ordering here is important
# don't try to set config_path if the user is trying
# to configure the aladdin config
if command != "config" and not env.set_config_path():
return sys.exit(1)
env.configure_env()

Expand Down
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.19.7.21"
version = "1.19.7.22"
description = ""
authors = ["Fivestars <dev@fivestars.com>"]
include = [
Expand Down

0 comments on commit 38a43a5

Please sign in to comment.