Integrate external plugins

This commit is contained in:
David Boreham 2023-10-09 12:40:28 -06:00
parent 9d19677aba
commit 9bcd94e014
3 changed files with 20 additions and 3 deletions

View File

@ -2,7 +2,7 @@ version: "1.1"
name: package-registry
description: "Local Package Registry"
repos:
- github.com/cerc-io/hosting
- git.vdb.to/cerc-io/hosting
- gitea.com/gitea/act_runner
containers:
- cerc/act-runner

View File

@ -22,7 +22,7 @@ import random
from shutil import copy, copyfile, copytree
import sys
from app.util import (get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml,
get_pod_list, get_pod_file_path, pod_has_scripts, get_pod_script_paths)
get_pod_list, get_pod_file_path, pod_has_scripts, get_pod_script_paths, get_plugin_code_path)
from app.deploy_types import DeploymentContext, DeployCommandContext, LaconicStackSetupCommand
@ -107,7 +107,9 @@ def _fixup_pod_file(pod, spec, compose_dir):
def _commands_plugin_path(ctx: DeployCommandContext):
return get_stack_file_path(ctx.stack).parent.joinpath("deploy", "commands.py")
plugin_path = get_plugin_code_path(ctx.stack)
print(f"Plugin path: {plugin_path}")
return plugin_path.joinpath("deploy", "commands.py")
def call_stack_deploy_init(deploy_command_context):
@ -130,6 +132,7 @@ def call_stack_deploy_setup(deploy_command_context, parameters: LaconicStackSetu
# Call a function in it
# If no function found, return None
python_file_path = _commands_plugin_path(deploy_command_context)
print(f"Path: {python_file_path}")
if python_file_path.exists():
spec = util.spec_from_file_location("commands", python_file_path)
imported_stack = util.module_from_spec(spec)
@ -145,6 +148,7 @@ def call_stack_deploy_create(deployment_context, extra_args):
# Call a function in it
# If no function found, return None
python_file_path = _commands_plugin_path(deployment_context.command_context)
print(f"Plugin is : {python_file_path}")
if python_file_path.exists():
spec = util.spec_from_file_location("commands", python_file_path)
imported_stack = util.module_from_spec(spec)

View File

@ -79,6 +79,19 @@ def get_pod_list(parsed_stack):
return result
def get_plugin_code_path(stack):
parsed_stack = get_parsed_stack_config(stack)
pods = parsed_stack["pods"]
# TODO: Hack
pod = pods[0]
if type(pod) is str:
result = get_stack_file_path(stack).parent
else:
pod_root_dir = os.path.join(get_dev_root_path(None), pod["repository"].split("/")[-1], pod["path"])
result = Path(os.path.join(pod_root_dir, "stack"))
return result
def get_pod_file_path(parsed_stack, pod_name: str):
pods = parsed_stack["pods"]
if type(pods[0]) is str: