Basic deploy commands for stack
This commit is contained in:
parent
56c3cb40c7
commit
ed0cc4bb37
25
app/data/stacks/mainnet-eth/deploy/commands.py
Normal file
25
app/data/stacks/mainnet-eth/deploy/commands.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Copyright © 2023 Cerc
|
||||||
|
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
def init(ctx):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def setup(ctx):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def create(ctx):
|
||||||
|
print("Yay it worked")
|
@ -59,7 +59,7 @@ def _get_named_volumes(stack):
|
|||||||
def _create_bind_dir_if_relative(volume, path_string, compose_dir):
|
def _create_bind_dir_if_relative(volume, path_string, compose_dir):
|
||||||
path = Path(path_string)
|
path = Path(path_string)
|
||||||
if not path.is_absolute():
|
if not path.is_absolute():
|
||||||
absolute_path = Path(compose_dir).joinpath(path)
|
absolute_path = Path(compose_dir).parent.joinpath(path)
|
||||||
absolute_path.mkdir(parents=True, exist_ok=True)
|
absolute_path.mkdir(parents=True, exist_ok=True)
|
||||||
else:
|
else:
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
@ -76,7 +76,7 @@ def _fixup_pod_file(pod, spec, compose_dir):
|
|||||||
for volume in pod_volumes.keys():
|
for volume in pod_volumes.keys():
|
||||||
if volume in spec_volumes:
|
if volume in spec_volumes:
|
||||||
volume_spec = spec_volumes[volume]
|
volume_spec = spec_volumes[volume]
|
||||||
volume_spec_fixedup = volume_spec if Path(volume_spec).is_absolute() else f"{volume_spec}"
|
volume_spec_fixedup = volume_spec if Path(volume_spec).is_absolute() else f".{volume_spec}"
|
||||||
_create_bind_dir_if_relative(volume, volume_spec, compose_dir)
|
_create_bind_dir_if_relative(volume, volume_spec, compose_dir)
|
||||||
new_volume_spec = {"driver": "local",
|
new_volume_spec = {"driver": "local",
|
||||||
"driver_opts": {
|
"driver_opts": {
|
||||||
@ -111,6 +111,18 @@ def call_stack_deploy_setup(stack):
|
|||||||
return imported_stack.setup(None)
|
return imported_stack.setup(None)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: fold this with function above
|
||||||
|
def call_stack_deploy_create(stack):
|
||||||
|
# Link with the python file in the stack
|
||||||
|
# Call a function in it
|
||||||
|
# If no function found, return None
|
||||||
|
python_file_path = get_stack_file_path(stack).parent.joinpath("deploy", "commands.py")
|
||||||
|
spec = util.spec_from_file_location("commands", python_file_path)
|
||||||
|
imported_stack = util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(imported_stack)
|
||||||
|
return imported_stack.create(None)
|
||||||
|
|
||||||
|
|
||||||
# Inspect the pod yaml to find config files referenced in subdirectories
|
# Inspect the pod yaml to find config files referenced in subdirectories
|
||||||
# other than the one associated with the pod
|
# other than the one associated with the pod
|
||||||
def _find_extra_config_dirs(parsed_pod_file, pod):
|
def _find_extra_config_dirs(parsed_pod_file, pod):
|
||||||
@ -138,7 +150,8 @@ def init(ctx, output):
|
|||||||
verbose = global_options(ctx).verbose
|
verbose = global_options(ctx).verbose
|
||||||
default_spec_file_content = call_stack_deploy_init(stack)
|
default_spec_file_content = call_stack_deploy_init(stack)
|
||||||
spec_file_content = {"stack": stack}
|
spec_file_content = {"stack": stack}
|
||||||
spec_file_content.update(default_spec_file_content)
|
if default_spec_file_content:
|
||||||
|
spec_file_content.update(default_spec_file_content)
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Creating spec file for stack: {stack}")
|
print(f"Creating spec file for stack: {stack}")
|
||||||
named_volumes = _get_named_volumes(stack)
|
named_volumes = _get_named_volumes(stack)
|
||||||
|
Loading…
Reference in New Issue
Block a user