Fail gracefully on bad stack
This commit is contained in:
parent
63ce394892
commit
918ef25f1a
@ -26,7 +26,7 @@ import importlib.resources
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import yaml
|
import yaml
|
||||||
from stack_orchestrator.constants import stack_file_name
|
from stack_orchestrator.constants import stack_file_name
|
||||||
from stack_orchestrator.util import include_exclude_check
|
from stack_orchestrator.util import include_exclude_check, error_exit
|
||||||
|
|
||||||
|
|
||||||
class GitProgress(git.RemoteProgress):
|
class GitProgress(git.RemoteProgress):
|
||||||
@ -245,6 +245,8 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches, branches
|
|||||||
# In order to be compatible with Python 3.8 we need to use this hack to get the path:
|
# In order to be compatible with Python 3.8 we need to use this hack to get the path:
|
||||||
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
||||||
stack_file_path = Path(__file__).absolute().parent.parent.joinpath("data", "stacks", stack, stack_file_name)
|
stack_file_path = Path(__file__).absolute().parent.parent.joinpath("data", "stacks", stack, stack_file_name)
|
||||||
|
if not stack_file_path.exists():
|
||||||
|
error_exit(f"stack {stack} does not exist")
|
||||||
with stack_file_path:
|
with stack_file_path:
|
||||||
stack_config = yaml.safe_load(open(stack_file_path, "r"))
|
stack_config = yaml.safe_load(open(stack_file_path, "r"))
|
||||||
# TODO: syntax check the input here
|
# TODO: syntax check the input here
|
||||||
|
@ -167,3 +167,8 @@ def global_options(ctx):
|
|||||||
# TODO: hack
|
# TODO: hack
|
||||||
def global_options2(ctx):
|
def global_options2(ctx):
|
||||||
return ctx.parent.obj
|
return ctx.parent.obj
|
||||||
|
|
||||||
|
|
||||||
|
def error_exit(s):
|
||||||
|
print(f"ERROR: {s}")
|
||||||
|
sys.exit(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user