forked from cerc-io/stack-orchestrator
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6df9ae0c1 | ||
|
|
f1cd13d988 | ||
|
|
edc24e4fc8 | ||
|
|
533ed4ee9b | ||
|
|
ba5eecaada | ||
|
|
5f73a93f5f | ||
|
|
135295f0f9 |
+19
-3
@@ -26,6 +26,7 @@ import subprocess
|
|||||||
import click
|
import click
|
||||||
import importlib.resources
|
import importlib.resources
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import yaml
|
||||||
from .util import include_exclude_check
|
from .util import include_exclude_check
|
||||||
|
|
||||||
# TODO: find a place for this
|
# TODO: find a place for this
|
||||||
@@ -43,6 +44,7 @@ def command(ctx, include, exclude):
|
|||||||
verbose = ctx.obj.verbose
|
verbose = ctx.obj.verbose
|
||||||
dry_run = ctx.obj.dry_run
|
dry_run = ctx.obj.dry_run
|
||||||
local_stack = ctx.obj.local_stack
|
local_stack = ctx.obj.local_stack
|
||||||
|
stack = ctx.obj.stack
|
||||||
|
|
||||||
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
||||||
container_build_dir = Path(__file__).absolute().parent.joinpath("data", "container-build")
|
container_build_dir = Path(__file__).absolute().parent.joinpath("data", "container-build")
|
||||||
@@ -62,10 +64,24 @@ def command(ctx, include, exclude):
|
|||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from . import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
||||||
containers = container_list_file.read().splitlines()
|
all_containers = container_list_file.read().splitlines()
|
||||||
|
|
||||||
|
containers_in_scope = []
|
||||||
|
if stack:
|
||||||
|
# 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.joinpath("data", "stacks", stack, "stack.yml")
|
||||||
|
with stack_file_path:
|
||||||
|
stack_config = yaml.safe_load(open(stack_file_path, "r"))
|
||||||
|
# TODO: syntax check the input here
|
||||||
|
containers_in_scope = stack_config['containers']
|
||||||
|
else:
|
||||||
|
containers_in_scope = all_containers
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f'Containers: {containers}')
|
print(f'Containers: {containers_in_scope}')
|
||||||
|
if stack:
|
||||||
|
print(f"Stack: {stack}")
|
||||||
|
|
||||||
# TODO: make this configurable
|
# TODO: make this configurable
|
||||||
container_build_env = {
|
container_build_env = {
|
||||||
@@ -101,7 +117,7 @@ def command(ctx, include, exclude):
|
|||||||
else:
|
else:
|
||||||
print("Skipped")
|
print("Skipped")
|
||||||
|
|
||||||
for container in containers:
|
for container in containers_in_scope:
|
||||||
if include_exclude_check(container, include, exclude):
|
if include_exclude_check(container, include, exclude):
|
||||||
process_container(container)
|
process_container(container)
|
||||||
else:
|
else:
|
||||||
|
|||||||
+18
-3
@@ -22,7 +22,9 @@ import os
|
|||||||
from decouple import config
|
from decouple import config
|
||||||
import click
|
import click
|
||||||
import importlib.resources
|
import importlib.resources
|
||||||
|
from pathlib import Path
|
||||||
from python_on_whales import docker
|
from python_on_whales import docker
|
||||||
|
import yaml
|
||||||
from .util import include_exclude_check
|
from .util import include_exclude_check
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@@ -37,6 +39,7 @@ def command(ctx, include, exclude):
|
|||||||
dry_run = ctx.obj.dry_run
|
dry_run = ctx.obj.dry_run
|
||||||
local_stack = ctx.obj.local_stack
|
local_stack = ctx.obj.local_stack
|
||||||
debug = ctx.obj.debug
|
debug = ctx.obj.debug
|
||||||
|
stack = ctx.obj.stack
|
||||||
|
|
||||||
if local_stack:
|
if local_stack:
|
||||||
dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")]
|
dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")]
|
||||||
@@ -53,10 +56,22 @@ def command(ctx, include, exclude):
|
|||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from . import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file:
|
with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file:
|
||||||
packages = package_list_file.read().splitlines()
|
all_packages = package_list_file.read().splitlines()
|
||||||
|
|
||||||
|
packages_in_scope = []
|
||||||
|
if stack:
|
||||||
|
# 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.joinpath("data", "stacks", stack, "stack.yml")
|
||||||
|
with stack_file_path:
|
||||||
|
stack_config = yaml.safe_load(open(stack_file_path, "r"))
|
||||||
|
# TODO: syntax check the input here
|
||||||
|
packages_in_scope = stack_config['npms']
|
||||||
|
else:
|
||||||
|
packages_in_scope = all_packages
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f'Packages: {packages}')
|
print(f'Packages: {packages_in_scope}')
|
||||||
|
|
||||||
def build_package(package):
|
def build_package(package):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
@@ -84,7 +99,7 @@ def command(ctx, include, exclude):
|
|||||||
else:
|
else:
|
||||||
print("Skipped")
|
print("Skipped")
|
||||||
|
|
||||||
for package in packages:
|
for package in packages_in_scope:
|
||||||
if include_exclude_check(package, include, exclude):
|
if include_exclude_check(package, include, exclude):
|
||||||
build_package(package)
|
build_package(package)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ repos:
|
|||||||
- cerc-io/laconicd
|
- cerc-io/laconicd
|
||||||
- cerc-io/laconic-sdk
|
- cerc-io/laconic-sdk
|
||||||
- cerc-io/laconic-registry-cli
|
- cerc-io/laconic-registry-cli
|
||||||
|
npms:
|
||||||
|
- laconic-sdk
|
||||||
|
- laconic-registry-cli
|
||||||
containers:
|
containers:
|
||||||
- cerc/laconicd
|
- cerc/laconicd
|
||||||
- cerc/laconic-registry-cli
|
- cerc/laconic-registry-cli
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
# This file should be re-generated running: scripts/update-version-file.sh script
|
# This file should be re-generated running: scripts/update-version-file.sh script
|
||||||
v1.0.9-alpha-04a3049
|
v1.0.10-alpha-4e1366d
|
||||||
|
|||||||
+17
-3
@@ -22,6 +22,7 @@ from python_on_whales import DockerClient
|
|||||||
import click
|
import click
|
||||||
import importlib.resources
|
import importlib.resources
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import yaml
|
||||||
from .util import include_exclude_check
|
from .util import include_exclude_check
|
||||||
|
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ def command(ctx, include, exclude, cluster, command, services):
|
|||||||
quiet = ctx.obj.quiet
|
quiet = ctx.obj.quiet
|
||||||
verbose = ctx.obj.verbose
|
verbose = ctx.obj.verbose
|
||||||
dry_run = ctx.obj.dry_run
|
dry_run = ctx.obj.dry_run
|
||||||
|
stack = ctx.obj.stack
|
||||||
|
|
||||||
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
||||||
compose_dir = Path(__file__).absolute().parent.joinpath("data", "compose")
|
compose_dir = Path(__file__).absolute().parent.joinpath("data", "compose")
|
||||||
@@ -56,15 +58,27 @@ def command(ctx, include, exclude, cluster, command, services):
|
|||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from . import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "pod-list.txt") as pod_list_file:
|
with importlib.resources.open_text(data, "pod-list.txt") as pod_list_file:
|
||||||
pods = pod_list_file.read().splitlines()
|
all_pods = pod_list_file.read().splitlines()
|
||||||
|
|
||||||
|
pods_in_scope = []
|
||||||
|
if stack:
|
||||||
|
# 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.joinpath("data", "stacks", stack, "stack.yml")
|
||||||
|
with stack_file_path:
|
||||||
|
stack_config = yaml.safe_load(open(stack_file_path, "r"))
|
||||||
|
# TODO: syntax check the input here
|
||||||
|
pods_in_scope = stack_config['pods']
|
||||||
|
else:
|
||||||
|
pods_in_scope = all_pods
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Pods: {pods}")
|
print(f"Pods: {pods_in_scope}")
|
||||||
|
|
||||||
# Construct a docker compose command suitable for our purpose
|
# Construct a docker compose command suitable for our purpose
|
||||||
|
|
||||||
compose_files = []
|
compose_files = []
|
||||||
for pod in pods:
|
for pod in pods_in_scope:
|
||||||
if include_exclude_check(pod, include, exclude):
|
if include_exclude_check(pod, include, exclude):
|
||||||
compose_file_name = os.path.join(compose_dir, f"docker-compose-{pod}.yml")
|
compose_file_name = os.path.join(compose_dir, f"docker-compose-{pod}.yml")
|
||||||
compose_files.append(compose_file_name)
|
compose_files.append(compose_file_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user