Integrate external plugins
This commit is contained in:
parent
9d19677aba
commit
9bcd94e014
@ -2,7 +2,7 @@ version: "1.1"
|
|||||||
name: package-registry
|
name: package-registry
|
||||||
description: "Local Package Registry"
|
description: "Local Package Registry"
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/hosting
|
- git.vdb.to/cerc-io/hosting
|
||||||
- gitea.com/gitea/act_runner
|
- gitea.com/gitea/act_runner
|
||||||
containers:
|
containers:
|
||||||
- cerc/act-runner
|
- cerc/act-runner
|
||||||
|
@ -22,7 +22,7 @@ import random
|
|||||||
from shutil import copy, copyfile, copytree
|
from shutil import copy, copyfile, copytree
|
||||||
import sys
|
import sys
|
||||||
from app.util import (get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml,
|
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
|
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):
|
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):
|
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
|
# Call a function in it
|
||||||
# If no function found, return None
|
# If no function found, return None
|
||||||
python_file_path = _commands_plugin_path(deploy_command_context)
|
python_file_path = _commands_plugin_path(deploy_command_context)
|
||||||
|
print(f"Path: {python_file_path}")
|
||||||
if python_file_path.exists():
|
if python_file_path.exists():
|
||||||
spec = util.spec_from_file_location("commands", python_file_path)
|
spec = util.spec_from_file_location("commands", python_file_path)
|
||||||
imported_stack = util.module_from_spec(spec)
|
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
|
# Call a function in it
|
||||||
# If no function found, return None
|
# If no function found, return None
|
||||||
python_file_path = _commands_plugin_path(deployment_context.command_context)
|
python_file_path = _commands_plugin_path(deployment_context.command_context)
|
||||||
|
print(f"Plugin is : {python_file_path}")
|
||||||
if python_file_path.exists():
|
if python_file_path.exists():
|
||||||
spec = util.spec_from_file_location("commands", python_file_path)
|
spec = util.spec_from_file_location("commands", python_file_path)
|
||||||
imported_stack = util.module_from_spec(spec)
|
imported_stack = util.module_from_spec(spec)
|
||||||
|
13
app/util.py
13
app/util.py
@ -79,6 +79,19 @@ def get_pod_list(parsed_stack):
|
|||||||
return result
|
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):
|
def get_pod_file_path(parsed_stack, pod_name: str):
|
||||||
pods = parsed_stack["pods"]
|
pods = parsed_stack["pods"]
|
||||||
if type(pods[0]) is str:
|
if type(pods[0]) is str:
|
||||||
|
Loading…
Reference in New Issue
Block a user