Check stack is a path
This commit is contained in:
parent
4ae4d3b61d
commit
63ce394892
16
stack_orchestrator/constants.py
Normal file
16
stack_orchestrator/constants.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Copyright © 2023 Vulcanize
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
stack_file_name = "stack.yml"
|
@ -25,6 +25,7 @@ import click
|
|||||||
import importlib.resources
|
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.util import include_exclude_check
|
from stack_orchestrator.util import include_exclude_check
|
||||||
|
|
||||||
|
|
||||||
@ -238,9 +239,12 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches, branches
|
|||||||
|
|
||||||
repos_in_scope = []
|
repos_in_scope = []
|
||||||
if stack:
|
if stack:
|
||||||
# In order to be compatible with Python 3.8 we need to use this hack to get the path:
|
# Check if the stack argument is a path or a plain string.
|
||||||
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
stack_file_path = Path(stack).joinpath(stack_file_name)
|
||||||
stack_file_path = Path(__file__).absolute().parent.parent.joinpath("data", "stacks", stack, "stack.yml")
|
if not stack_file_path.exists():
|
||||||
|
# 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
|
||||||
|
stack_file_path = Path(__file__).absolute().parent.parent.joinpath("data", "stacks", stack, stack_file_name)
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user