forked from cerc-io/stack-orchestrator
Tolerate missing deployment plugin source code files (#508)
This commit is contained in:
parent
97dc45549d
commit
f411590452
@ -14,7 +14,6 @@
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
import click
|
||||
from dataclasses import dataclass
|
||||
from importlib import util
|
||||
import os
|
||||
from pathlib import Path
|
||||
@ -27,6 +26,7 @@ from app.deploy_types import DeploymentContext, DeployCommandContext
|
||||
def _make_default_deployment_dir():
|
||||
return "deployment-001"
|
||||
|
||||
|
||||
def _get_ports(stack):
|
||||
ports = {}
|
||||
parsed_stack = get_parsed_stack_config(stack)
|
||||
@ -42,6 +42,7 @@ def _get_ports(stack):
|
||||
ports[svc_name] = [ str(x) for x in svc["ports"] ]
|
||||
return ports
|
||||
|
||||
|
||||
def _get_named_volumes(stack):
|
||||
# Parse the compose files looking for named volumes
|
||||
named_volumes = []
|
||||
@ -107,10 +108,13 @@ def call_stack_deploy_init(deploy_command_context):
|
||||
# Call a function in it
|
||||
# If no function found, return None
|
||||
python_file_path = get_stack_file_path(deploy_command_context.stack).parent.joinpath("deploy", "commands.py")
|
||||
if python_file_path.exists():
|
||||
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.init(deploy_command_context)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
# TODO: fold this with function above
|
||||
@ -119,10 +123,13 @@ def call_stack_deploy_setup(deploy_command_context, extra_args):
|
||||
# Call a function in it
|
||||
# If no function found, return None
|
||||
python_file_path = get_stack_file_path(deploy_command_context.stack).parent.joinpath("deploy", "commands.py")
|
||||
if python_file_path.exists():
|
||||
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.setup(deploy_command_context, extra_args)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
# TODO: fold this with function above
|
||||
@ -131,10 +138,13 @@ def call_stack_deploy_create(deployment_context):
|
||||
# Call a function in it
|
||||
# If no function found, return None
|
||||
python_file_path = get_stack_file_path(deployment_context.command_context.stack).parent.joinpath("deploy", "commands.py")
|
||||
if python_file_path.exists():
|
||||
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(deployment_context)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
# Inspect the pod yaml to find config files referenced in subdirectories
|
||||
|
Loading…
Reference in New Issue
Block a user