Fix lint errors #523
@ -63,7 +63,8 @@ class package_registry_stack(base_stack):
|
|||||||
self.url = "http://gitea.local:3000/api/packages/cerc-io/npm/"
|
self.url = "http://gitea.local:3000/api/packages/cerc-io/npm/"
|
||||||
else:
|
else:
|
||||||
# If not, print a message about how to start it and return fail to the caller
|
# If not, print a message about how to start it and return fail to the caller
|
||||||
print("ERROR: The package-registry stack is not running, and no external registry specified with CERC_NPM_REGISTRY_URL")
|
print("ERROR: The package-registry stack is not running, and no external registry "
|
||||||
|
"specified with CERC_NPM_REGISTRY_URL")
|
||||||
print("ERROR: Start the local package registry with: laconic-so --stack package-registry deploy-system up")
|
print("ERROR: Start the local package registry with: laconic-so --stack package-registry deploy-system up")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@ -75,5 +76,7 @@ class package_registry_stack(base_stack):
|
|||||||
def get_npm_registry_url():
|
def get_npm_registry_url():
|
||||||
# If an auth token is not defined, we assume the default should be the cerc registry
|
# If an auth token is not defined, we assume the default should be the cerc registry
|
||||||
# If an auth token is defined, we assume the local gitea should be used.
|
# If an auth token is defined, we assume the local gitea should be used.
|
||||||
default_npm_registry_url = "http://gitea.local:3000/api/packages/cerc-io/npm/" if config("CERC_NPM_AUTH_TOKEN", default=None) else "https://git.vdb.to/api/packages/cerc-io/npm/"
|
default_npm_registry_url = "http://gitea.local:3000/api/packages/cerc-io/npm/" if config(
|
||||||
|
"CERC_NPM_AUTH_TOKEN", default=None
|
||||||
|
) else "https://git.vdb.to/api/packages/cerc-io/npm/"
|
||||||
return config("CERC_NPM_REGISTRY_URL", default=default_npm_registry_url)
|
return config("CERC_NPM_REGISTRY_URL", default=default_npm_registry_url)
|
||||||
|
@ -30,10 +30,12 @@ from app.util import include_exclude_check, get_parsed_stack_config
|
|||||||
|
|
||||||
builder_js_image_name = "cerc/builder-js:local"
|
builder_js_image_name = "cerc/builder-js:local"
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option('--include', help="only build these packages")
|
@click.option('--include', help="only build these packages")
|
||||||
@click.option('--exclude', help="don\'t build these packages")
|
@click.option('--exclude', help="don\'t build these packages")
|
||||||
@click.option("--force-rebuild", is_flag=True, default=False, help="Override existing target package version check -- force rebuild")
|
@click.option("--force-rebuild", is_flag=True, default=False,
|
||||||
|
help="Override existing target package version check -- force rebuild")
|
||||||
@click.option("--extra-build-args", help="Supply extra arguments to build")
|
@click.option("--extra-build-args", help="Supply extra arguments to build")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
||||||
|
@ -101,7 +101,8 @@ if __name__ == "__main__":
|
|||||||
if args.ssh_host:
|
if args.ssh_host:
|
||||||
dst_dbport = random.randint(11000, 12000)
|
dst_dbport = random.randint(11000, 12000)
|
||||||
print(
|
print(
|
||||||
f"Establishing SSH tunnel from 127.0.0.1:{dst_dbport} to {args.ssh_host}->{args.dst_dbhost}:{args.dst_dbport}... ",
|
f"Establishing SSH tunnel from 127.0.0.1:{dst_dbport} to "
|
||||||
|
"{args.ssh_host}->{args.dst_dbhost}:{args.dst_dbport}... ",
|
||||||
end="",
|
end="",
|
||||||
)
|
)
|
||||||
with Connection(
|
with Connection(
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from web3.auto import w3
|
from web3.auto import w3
|
||||||
import json
|
|
||||||
import ruamel.yaml as yaml
|
import ruamel.yaml as yaml
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
from secrets import token_hex
|
from secrets import token_hex
|
||||||
|
|
||||||
|
|
||||||
def init(ctx):
|
def init(ctx):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ def exec_operation(ctx, extra_args):
|
|||||||
print(f"Running compose exec {service_name} {command_to_exec}")
|
print(f"Running compose exec {service_name} {command_to_exec}")
|
||||||
try:
|
try:
|
||||||
ctx.obj.docker.compose.execute(service_name, command_to_exec, envs=container_exec_env)
|
ctx.obj.docker.compose.execute(service_name, command_to_exec, envs=container_exec_env)
|
||||||
except DockerException as error:
|
except DockerException:
|
||||||
print(f"container command returned error exit status")
|
print("container command returned error exit status")
|
||||||
|
|
||||||
|
|
||||||
def logs_operation(ctx, tail: int, follow: bool, extra_args: str):
|
def logs_operation(ctx, tail: int, follow: bool, extra_args: str):
|
||||||
|
@ -19,6 +19,7 @@ from pathlib import Path
|
|||||||
from python_on_whales import DockerClient
|
from python_on_whales import DockerClient
|
||||||
from app.command_types import CommandOptions
|
from app.command_types import CommandOptions
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ClusterContext:
|
class ClusterContext:
|
||||||
options: CommandOptions # TODO: this should be in its own object not stuffed in here
|
options: CommandOptions # TODO: this should be in its own object not stuffed in here
|
||||||
|
@ -19,7 +19,7 @@ from app.deploy_types import DeployCommandContext, VolumeMapping
|
|||||||
from app.util import get_parsed_stack_config, get_yaml, get_compose_file_dir
|
from app.util import get_parsed_stack_config, get_yaml, get_compose_file_dir
|
||||||
|
|
||||||
|
|
||||||
def _container_image_from_service(stack :str, service: str):
|
def _container_image_from_service(stack: str, service: str):
|
||||||
# Parse the compose files looking for the image name of the specified service
|
# Parse the compose files looking for the image name of the specified service
|
||||||
image_name = None
|
image_name = None
|
||||||
parsed_stack = get_parsed_stack_config(stack)
|
parsed_stack = get_parsed_stack_config(stack)
|
||||||
|
@ -17,8 +17,8 @@ import click
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
from app.deploy import up_operation, down_operation, ps_operation, port_operation, exec_operation, logs_operation, create_deploy_context
|
from app.deploy import up_operation, down_operation, ps_operation, port_operation
|
||||||
from app.util import global_options
|
from app.deploy import exec_operation, logs_operation, create_deploy_context
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -41,7 +41,7 @@ def _get_ports(stack):
|
|||||||
for svc_name, svc in parsed_pod_file["services"].items():
|
for svc_name, svc in parsed_pod_file["services"].items():
|
||||||
if "ports" in svc:
|
if "ports" in svc:
|
||||||
# Ports can appear as strings or numbers. We normalize them as strings.
|
# Ports can appear as strings or numbers. We normalize them as strings.
|
||||||
ports[svc_name] = [ str(x) for x in svc["ports"] ]
|
ports[svc_name] = [str(x) for x in svc["ports"]]
|
||||||
return ports
|
return ports
|
||||||
|
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ def _get_mapped_ports(stack: str, map_recipe: str):
|
|||||||
ports_array = ports[service]
|
ports_array = ports[service]
|
||||||
for x in range(0, len(ports_array)):
|
for x in range(0, len(ports_array)):
|
||||||
orig_port = ports_array[x]
|
orig_port = ports_array[x]
|
||||||
random_port = random.randint(20000,50000) # Beware: we're relying on luck to not collide
|
random_port = random.randint(20000, 50000) # Beware: we're relying on luck to not collide
|
||||||
if map_recipe == "any-variable-random":
|
if map_recipe == "any-variable-random":
|
||||||
# This is the default so take no action
|
# This is the default so take no action
|
||||||
pass
|
pass
|
||||||
@ -202,11 +202,11 @@ def _get_mapped_ports(stack: str, map_recipe: str):
|
|||||||
return ports
|
return ports
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--output", required=True, help="Write yaml spec file here")
|
@click.option("--output", required=True, help="Write yaml spec file here")
|
||||||
@click.option("--map-ports-to-host", required=False,
|
@click.option("--map-ports-to-host", required=False,
|
||||||
help="Map ports to the host as one of: any-variable-random (default), localhost-same, any-same, localhost-fixed-random, any-fixed-random")
|
help="Map ports to the host as one of: any-variable-random (default), "
|
||||||
|
"localhost-same, any-same, localhost-fixed-random, any-fixed-random")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def init(ctx, output, map_ports_to_host):
|
def init(ctx, output, map_ports_to_host):
|
||||||
yaml = get_yaml()
|
yaml = get_yaml()
|
||||||
|
@ -76,7 +76,7 @@ def _get_repo_current_branch_or_tag(full_filesystem_repo_path):
|
|||||||
try:
|
try:
|
||||||
current_repo_branch_or_tag = git.Repo(full_filesystem_repo_path).active_branch.name
|
current_repo_branch_or_tag = git.Repo(full_filesystem_repo_path).active_branch.name
|
||||||
is_branch = True
|
is_branch = True
|
||||||
except TypeError as error:
|
except TypeError:
|
||||||
# This means that the current ref is not a branch, so possibly a tag
|
# This means that the current ref is not a branch, so possibly a tag
|
||||||
# Let's try to get the tag
|
# Let's try to get the tag
|
||||||
current_repo_branch_or_tag = git.Repo(full_filesystem_repo_path).git.describe("--tags", "--exact-match")
|
current_repo_branch_or_tag = git.Repo(full_filesystem_repo_path).git.describe("--tags", "--exact-match")
|
||||||
@ -96,7 +96,9 @@ def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_pa
|
|||||||
repoName = repo_path.split("/")[-1]
|
repoName = repo_path.split("/")[-1]
|
||||||
full_filesystem_repo_path = os.path.join(dev_root_path, repoName)
|
full_filesystem_repo_path = os.path.join(dev_root_path, repoName)
|
||||||
is_present = os.path.isdir(full_filesystem_repo_path)
|
is_present = os.path.isdir(full_filesystem_repo_path)
|
||||||
(current_repo_branch_or_tag, is_branch) = _get_repo_current_branch_or_tag(full_filesystem_repo_path) if is_present else (None, None)
|
(current_repo_branch_or_tag, is_branch) = _get_repo_current_branch_or_tag(
|
||||||
|
full_filesystem_repo_path
|
||||||
|
) if is_present else (None, None)
|
||||||
if not quiet:
|
if not quiet:
|
||||||
present_text = f"already exists active {'branch' if is_branch else 'tag'}: {current_repo_branch_or_tag}" if is_present \
|
present_text = f"already exists active {'branch' if is_branch else 'tag'}: {current_repo_branch_or_tag}" if is_present \
|
||||||
else 'Needs to be fetched'
|
else 'Needs to be fetched'
|
||||||
@ -116,7 +118,7 @@ def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_pa
|
|||||||
origin = git_repo.remotes.origin
|
origin = git_repo.remotes.origin
|
||||||
origin.pull(progress=None if quiet else GitProgress())
|
origin.pull(progress=None if quiet else GitProgress())
|
||||||
else:
|
else:
|
||||||
print(f"skipping pull because this repo checked out a tag")
|
print("skipping pull because this repo checked out a tag")
|
||||||
else:
|
else:
|
||||||
print("(git pull skipped)")
|
print("(git pull skipped)")
|
||||||
if not is_present:
|
if not is_present:
|
||||||
@ -143,7 +145,10 @@ def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_pa
|
|||||||
branch_to_checkout = repo_branch
|
branch_to_checkout = repo_branch
|
||||||
|
|
||||||
if branch_to_checkout:
|
if branch_to_checkout:
|
||||||
if current_repo_branch_or_tag is None or (current_repo_branch_or_tag and (current_repo_branch_or_tag != branch_to_checkout)):
|
if current_repo_branch_or_tag is None or (
|
||||||
|
current_repo_branch_or_tag and (
|
||||||
|
current_repo_branch_or_tag != branch_to_checkout)
|
||||||
|
):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(f"switching to branch {branch_to_checkout} in repo {repo_path}")
|
print(f"switching to branch {branch_to_checkout} in repo {repo_path}")
|
||||||
git_repo = git.Repo(full_filesystem_repo_path)
|
git_repo = git.Repo(full_filesystem_repo_path)
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
import click
|
import click
|
||||||
import importlib.resources
|
import importlib.resources
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def command(ctx):
|
def command(ctx):
|
||||||
|
1
cli.py
1
cli.py
@ -14,7 +14,6 @@
|
|||||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from dataclasses import dataclass
|
|
||||||
|
|
||||||
from app.command_types import CommandOptions
|
from app.command_types import CommandOptions
|
||||||
from app import setup_repositories
|
from app import setup_repositories
|
||||||
|
Loading…
Reference in New Issue
Block a user