edge-containers-cli 3.5.5__tar.gz → 4.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/workflows/_release.yml +1 -1
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/workflows/ci.yml +0 -13
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/PKG-INFO +2 -2
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/pyproject.toml +1 -1
- edge_containers_cli-4.0.0/src/edge_containers_cli/__init__.py +13 -0
- edge_containers_cli-4.0.0/src/edge_containers_cli/__main__.py +122 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli/_version.py +2 -2
- edge_containers_cli-4.0.0/src/edge_containers_cli/autocomplete.py +96 -0
- edge_containers_cli-4.0.0/src/edge_containers_cli/backend.py +62 -0
- edge_containers_cli-4.0.0/src/edge_containers_cli/cli.py +270 -0
- edge_containers_cli-4.0.0/src/edge_containers_cli/cmds/argo_commands.py +158 -0
- edge_containers_cli-4.0.0/src/edge_containers_cli/cmds/commands.py +143 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli/cmds/helm.py +39 -42
- edge_containers_cli-4.0.0/src/edge_containers_cli/cmds/k8s_commands.py +188 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli/cmds/monitor.py +19 -22
- edge_containers_cli-4.0.0/src/edge_containers_cli/definitions.py +33 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli/git.py +70 -32
- edge_containers_cli-4.0.0/src/edge_containers_cli/globals.py +20 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli/logging.py +3 -5
- edge_containers_cli-4.0.0/src/edge_containers_cli/shell.py +126 -0
- edge_containers_cli-4.0.0/src/edge_containers_cli/utils.py +114 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli.egg-info/PKG-INFO +2 -2
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli.egg-info/SOURCES.txt +19 -29
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli.egg-info/requires.txt +1 -1
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/tests/conftest.py +74 -67
- edge_containers_cli-4.0.0/tests/data/argocd.yaml +45 -0
- edge_containers_cli-4.0.0/tests/data/bl01t/services/bl01t-ea-test-01/Chart.yaml +14 -0
- edge_containers_cli-4.0.0/tests/data/bl01t/services/bl01t-ea-test-01/config/ioc.db +6 -0
- {edge_containers_cli-3.5.5/tests/data/bl01t/include/iocs → edge_containers_cli-4.0.0/tests/data/bl01t/services/bl01t-ea-test-01}/templates/configmap.yaml +1 -1
- edge_containers_cli-4.0.0/tests/data/bl01t/services/bl01t-ea-test-01/values.yaml +3 -0
- edge_containers_cli-4.0.0/tests/data/bl01t/services/bl01t-ea-test-02/Chart.yaml +14 -0
- edge_containers_cli-4.0.0/tests/data/bl01t/services/bl01t-ea-test-02/values.yaml +3 -0
- edge_containers_cli-4.0.0/tests/data/bl01t/services/dls-aravis/Chart.yaml +7 -0
- edge_containers_cli-4.0.0/tests/data/bl01t/services/dls-aravis/config/ioc.yaml +28 -0
- edge_containers_cli-4.0.0/tests/data/bl01t/services/dls-aravis/templates/configmap.yaml +10 -0
- edge_containers_cli-4.0.0/tests/data/bl01t/services/dls-aravis/values.yaml +17 -0
- edge_containers_cli-4.0.0/tests/data/bl01t/services/values.yaml +3 -0
- edge_containers_cli-4.0.0/tests/data/cli.yaml +24 -0
- edge_containers_cli-4.0.0/tests/data/k8s.yaml +79 -0
- edge_containers_cli-4.0.0/tests/test_argocd.py +35 -0
- edge_containers_cli-4.0.0/tests/test_cli.py +44 -0
- edge_containers_cli-4.0.0/tests/test_k8s.py +73 -0
- edge_containers_cli-3.5.5/.github/workflows/_sys_test.yml +0 -36
- edge_containers_cli-3.5.5/src/edge_containers_cli/__init__.py +0 -3
- edge_containers_cli-3.5.5/src/edge_containers_cli/__main__.py +0 -69
- edge_containers_cli-3.5.5/src/edge_containers_cli/autocomplete.py +0 -140
- edge_containers_cli-3.5.5/src/edge_containers_cli/cmds/cli.py +0 -317
- edge_containers_cli-3.5.5/src/edge_containers_cli/cmds/commands.py +0 -86
- edge_containers_cli-3.5.5/src/edge_containers_cli/cmds/k8s_commands.py +0 -237
- edge_containers_cli-3.5.5/src/edge_containers_cli/cmds/kubectl.py +0 -15
- edge_containers_cli-3.5.5/src/edge_containers_cli/cmds/local_commands.py +0 -291
- edge_containers_cli-3.5.5/src/edge_containers_cli/docker.py +0 -165
- edge_containers_cli-3.5.5/src/edge_containers_cli/globals.py +0 -54
- edge_containers_cli-3.5.5/src/edge_containers_cli/shell.py +0 -91
- edge_containers_cli-3.5.5/src/edge_containers_cli/utils.py +0 -131
- edge_containers_cli-3.5.5/tests/data/autocomplete.yaml +0 -62
- edge_containers_cli-3.5.5/tests/data/bl01t/.copier-answers.yml +0 -10
- edge_containers_cli-3.5.5/tests/data/bl01t/.github/dependabot.yml +0 -12
- edge_containers_cli-3.5.5/tests/data/bl01t/.github/workflows/ci_verify.sh +0 -36
- edge_containers_cli-3.5.5/tests/data/bl01t/.github/workflows/verify.yml +0 -16
- edge_containers_cli-3.5.5/tests/data/bl01t/.gitignore +0 -8
- edge_containers_cli-3.5.5/tests/data/bl01t/LICENSE +0 -201
- edge_containers_cli-3.5.5/tests/data/bl01t/README.md +0 -8
- edge_containers_cli-3.5.5/tests/data/bl01t/environment.sh +0 -52
- edge_containers_cli-3.5.5/tests/data/bl01t/helm/shared/Chart.yaml +0 -13
- edge_containers_cli-3.5.5/tests/data/bl01t/helm/shared/README.md +0 -21
- edge_containers_cli-3.5.5/tests/data/bl01t/helm/shared/values.yaml +0 -85
- edge_containers_cli-3.5.5/tests/data/bl01t/include/iocs/Chart.yaml +0 -21
- edge_containers_cli-3.5.5/tests/data/bl01t/services/bl01t-ea-test-01/Chart.yaml +0 -21
- edge_containers_cli-3.5.5/tests/data/bl01t/services/bl01t-ea-test-01/config/ioc.db +0 -26
- edge_containers_cli-3.5.5/tests/data/bl01t/services/bl01t-ea-test-01/pretend_helm.tgz +0 -0
- edge_containers_cli-3.5.5/tests/data/bl01t/services/bl01t-ea-test-01/values.yaml +0 -4
- edge_containers_cli-3.5.5/tests/data/bl01t/update-helm +0 -19
- edge_containers_cli-3.5.5/tests/data/ioc.yaml +0 -111
- edge_containers_cli-3.5.5/tests/data/local.yaml +0 -164
- edge_containers_cli-3.5.5/tests/test_autocomplete.py +0 -84
- edge_containers_cli-3.5.5/tests/test_cli.py +0 -9
- edge_containers_cli-3.5.5/tests/test_ioc.py +0 -91
- edge_containers_cli-3.5.5/tests/test_local.py +0 -76
- edge_containers_cli-3.5.5/tests/test_system.py +0 -49
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.copier-answers.yml +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.devcontainer/devcontainer.json +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/CONTRIBUTING.md +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/actions/install_requirements/action.yml +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/dependabot.yml +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/pages/index.html +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/pages/make_switcher.py +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/workflows/_check.yml +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/workflows/_dist.yml +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/workflows/_pypi.yml +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/workflows/_test.yml +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.github/workflows/_tox.yml +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.gitignore +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.pre-commit-config.yaml +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.vscode/extensions.json +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.vscode/launch.json +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.vscode/settings.json +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/.vscode/tasks.json +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/Dockerfile +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/LICENSE +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/README.md +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/catalog-info.yaml +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/conf.py +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/explanations/decisions/0001-record-architecture-decisions.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/explanations/decisions/0002-switched-to-pip-skeleton.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/explanations/decisions.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/how-to/build-docs.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/how-to/contribute.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/how-to/lint.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/how-to/make-release.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/how-to/pin-requirements.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/how-to/run-tests.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/how-to/static-analysis.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/how-to/test-container.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/how-to/update-tools.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/index.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/reference/standards.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/developer/tutorials/dev-install.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/genindex.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/images/dls-favicon.ico +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/images/dls-logo.svg +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/index.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/user/explanations/docs-structure.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/user/how-to/run-container.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/user/index.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/user/reference/api.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/docs/user/tutorials/installation.rst +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/setup.cfg +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli/cmds/__init__.py +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli/cmds/monitor.tcss +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli.egg-info/dependency_links.txt +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli.egg-info/entry_points.txt +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/src/edge_containers_cli.egg-info/top_level.txt +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/tests/__init__.py +0 -0
- {edge_containers_cli-3.5.5 → edge_containers_cli-4.0.0}/tests/data/bl01t/services/bl01t-ea-test-01/config/ioc.yaml +0 -0
|
@@ -23,7 +23,7 @@ jobs:
|
|
|
23
23
|
- name: Create GitHub Release
|
|
24
24
|
# We pin to the SHA, not the tag, for security reasons.
|
|
25
25
|
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
|
|
26
|
-
uses: softprops/action-gh-release@
|
|
26
|
+
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v0.1.15
|
|
27
27
|
with:
|
|
28
28
|
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
|
|
29
29
|
files: "*"
|
|
@@ -34,19 +34,6 @@ jobs:
|
|
|
34
34
|
secrets:
|
|
35
35
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
36
36
|
|
|
37
|
-
system:
|
|
38
|
-
needs: check
|
|
39
|
-
if: needs.check.outputs.branch-pr == ''
|
|
40
|
-
strategy:
|
|
41
|
-
matrix:
|
|
42
|
-
runs-on: ["ubuntu-latest"]
|
|
43
|
-
python-version: ["3.12"]
|
|
44
|
-
fail-fast: false
|
|
45
|
-
uses: ./.github/workflows/_sys_test.yml
|
|
46
|
-
with:
|
|
47
|
-
runs-on: ${{ matrix.runs-on }}
|
|
48
|
-
python-version: ${{ matrix.python-version }}
|
|
49
|
-
|
|
50
37
|
dist:
|
|
51
38
|
needs: check
|
|
52
39
|
if: needs.check.outputs.branch-pr == ''
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: edge-containers-cli
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: CLI for deploying and managing epics containers IOCs and services
|
|
5
5
|
Author-email: Giles Knap <giles.knap@gmail.com>
|
|
6
6
|
License: Apache License
|
|
@@ -219,7 +219,7 @@ Requires-Dist: typer[all]
|
|
|
219
219
|
Requires-Dist: requests
|
|
220
220
|
Requires-Dist: ruamel.yaml
|
|
221
221
|
Requires-Dist: jinja2
|
|
222
|
-
Requires-Dist: polars
|
|
222
|
+
Requires-Dist: polars-lts-cpu
|
|
223
223
|
Requires-Dist: textual
|
|
224
224
|
Provides-Extra: dev
|
|
225
225
|
Requires-Dist: copier; extra == "dev"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import polars
|
|
2
|
+
|
|
3
|
+
from ._version import __version__
|
|
4
|
+
|
|
5
|
+
__all__ = ["__version__"]
|
|
6
|
+
|
|
7
|
+
# Set formatting of polars tables
|
|
8
|
+
polars.Config.set_tbl_hide_column_data_types(True)
|
|
9
|
+
polars.Config.set_tbl_hide_dataframe_shape(True)
|
|
10
|
+
polars.Config.set_tbl_rows(-1)
|
|
11
|
+
polars.Config.set_tbl_cols(-1)
|
|
12
|
+
polars.Config.set_fmt_str_lengths(82)
|
|
13
|
+
polars.Config.set_tbl_formatting("ASCII_MARKDOWN")
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from edge_containers_cli.cli import cli
|
|
6
|
+
from edge_containers_cli.definitions import ENV, ECBackends, ECContext, ECLogLevels
|
|
7
|
+
|
|
8
|
+
from . import __version__
|
|
9
|
+
from .backend import backend as ec_backend
|
|
10
|
+
from .backend import init_backend
|
|
11
|
+
from .logging import init_logging
|
|
12
|
+
from .shell import init_shell
|
|
13
|
+
from .utils import init_cleanup
|
|
14
|
+
|
|
15
|
+
__all__ = ["main"]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def version_callback(value: bool):
|
|
19
|
+
if value:
|
|
20
|
+
typer.echo(__version__)
|
|
21
|
+
raise typer.Exit()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def backend_callback(ctx: typer.Context, backend: ECBackends):
|
|
25
|
+
init_backend(backend)
|
|
26
|
+
# Dynamically drop any method not implemented
|
|
27
|
+
not_implemented = [
|
|
28
|
+
mthd.replace("_", "-") for mthd in ec_backend.get_notimplemented()
|
|
29
|
+
]
|
|
30
|
+
for command in not_implemented:
|
|
31
|
+
typer_commands = ctx.command.commands # type: ignore
|
|
32
|
+
if command in typer_commands:
|
|
33
|
+
typer_commands.pop(command)
|
|
34
|
+
|
|
35
|
+
return backend.value
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@cli.callback()
|
|
39
|
+
def main(
|
|
40
|
+
ctx: typer.Context,
|
|
41
|
+
version: Optional[bool] = typer.Option(
|
|
42
|
+
None,
|
|
43
|
+
"--version",
|
|
44
|
+
callback=version_callback,
|
|
45
|
+
is_eager=True,
|
|
46
|
+
help="Log the version of ec and exit",
|
|
47
|
+
),
|
|
48
|
+
repo: str = typer.Option(
|
|
49
|
+
ECContext().repo,
|
|
50
|
+
"-r",
|
|
51
|
+
"--repo",
|
|
52
|
+
help="Service instances repository",
|
|
53
|
+
envvar=ENV.repo.value,
|
|
54
|
+
),
|
|
55
|
+
target: str = typer.Option(
|
|
56
|
+
ECContext().target,
|
|
57
|
+
"-t",
|
|
58
|
+
"--target",
|
|
59
|
+
help="K8S namespace or ARGOCD app-namespace/root-app",
|
|
60
|
+
envvar=ENV.target.value,
|
|
61
|
+
),
|
|
62
|
+
backend: ECBackends = typer.Option(
|
|
63
|
+
ECBackends.ARGOCD,
|
|
64
|
+
"-b",
|
|
65
|
+
"--backend",
|
|
66
|
+
callback=backend_callback,
|
|
67
|
+
is_eager=True,
|
|
68
|
+
help="Backend to use",
|
|
69
|
+
envvar=ENV.backend.value,
|
|
70
|
+
expose_value=True,
|
|
71
|
+
),
|
|
72
|
+
verbose: bool = typer.Option(
|
|
73
|
+
False,
|
|
74
|
+
"-v",
|
|
75
|
+
"--verbose",
|
|
76
|
+
help="Print the commands we run",
|
|
77
|
+
envvar=ENV.verbose.value,
|
|
78
|
+
show_default=True,
|
|
79
|
+
),
|
|
80
|
+
dryrun: bool = typer.Option(
|
|
81
|
+
False,
|
|
82
|
+
"--dryrun",
|
|
83
|
+
help="Print the commands we run without execution",
|
|
84
|
+
envvar=ENV.dryrun.value,
|
|
85
|
+
show_default=True,
|
|
86
|
+
),
|
|
87
|
+
debug: bool = typer.Option(
|
|
88
|
+
False,
|
|
89
|
+
"-d",
|
|
90
|
+
"--debug",
|
|
91
|
+
help="Enable debug logging, retain temp files",
|
|
92
|
+
envvar=ENV.debug.value,
|
|
93
|
+
show_default=True,
|
|
94
|
+
),
|
|
95
|
+
log_level: ECLogLevels = typer.Option(
|
|
96
|
+
ECLogLevels.WARNING,
|
|
97
|
+
help="Log level",
|
|
98
|
+
envvar=ENV.log_level.value,
|
|
99
|
+
),
|
|
100
|
+
log_url: str = typer.Option(
|
|
101
|
+
ECContext().log_url,
|
|
102
|
+
help="Log url",
|
|
103
|
+
envvar=ENV.log_url.value,
|
|
104
|
+
),
|
|
105
|
+
):
|
|
106
|
+
"""Edge Containers assistant CLI"""
|
|
107
|
+
init_logging(ECLogLevels.DEBUG if debug else log_level)
|
|
108
|
+
init_shell(verbose, dryrun)
|
|
109
|
+
init_cleanup(debug)
|
|
110
|
+
|
|
111
|
+
context = ECContext(
|
|
112
|
+
repo=repo,
|
|
113
|
+
target=target,
|
|
114
|
+
log_url=log_url,
|
|
115
|
+
)
|
|
116
|
+
ec_backend.set_context(context)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# test with:
|
|
120
|
+
# python -m edge_containers_cli
|
|
121
|
+
if __name__ == "__main__":
|
|
122
|
+
cli()
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import urllib
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
import edge_containers_cli.globals as globals
|
|
7
|
+
from edge_containers_cli.backend import backend as ec_backend
|
|
8
|
+
from edge_containers_cli.cmds.commands import CommandError
|
|
9
|
+
from edge_containers_cli.definitions import ECContext
|
|
10
|
+
from edge_containers_cli.git import GitError, create_version_map
|
|
11
|
+
from edge_containers_cli.shell import ShellError
|
|
12
|
+
from edge_containers_cli.utils import cache_dict, new_workdir, read_cached_dict
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def url_encode(in_string: str) -> str:
|
|
16
|
+
return urllib.parse.quote(in_string, safe="") # type: ignore
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def autocomplete_backend_init(ctx: typer.Context):
|
|
20
|
+
params = ctx.parent.params # type: ignore
|
|
21
|
+
context = ECContext(
|
|
22
|
+
repo=params["repo"],
|
|
23
|
+
target=params["target"],
|
|
24
|
+
log_url=params["log_url"],
|
|
25
|
+
)
|
|
26
|
+
ec_backend.set_context(context)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def fetch_service_graph(repo: str) -> dict:
|
|
30
|
+
version_map = read_cached_dict(
|
|
31
|
+
globals.CACHE_ROOT / url_encode(repo), globals.SERVICE_CACHE
|
|
32
|
+
)
|
|
33
|
+
if not version_map:
|
|
34
|
+
with new_workdir() as path:
|
|
35
|
+
version_map = create_version_map(
|
|
36
|
+
repo, Path(globals.SERVICES_DIR), path, shared=[globals.SHARED_VALUES]
|
|
37
|
+
)
|
|
38
|
+
cache_dict(
|
|
39
|
+
globals.CACHE_ROOT / url_encode(repo),
|
|
40
|
+
globals.SERVICE_CACHE,
|
|
41
|
+
version_map,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return version_map
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def avail_services(ctx: typer.Context) -> list[str]:
|
|
48
|
+
autocomplete_backend_init(ctx)
|
|
49
|
+
|
|
50
|
+
# This block prevents getting a stack trace during autocompletion
|
|
51
|
+
try:
|
|
52
|
+
services_graph = fetch_service_graph(ec_backend.commands.repo)
|
|
53
|
+
return list(services_graph.keys())
|
|
54
|
+
except (ShellError, CommandError) as e:
|
|
55
|
+
typer.echo(f"\n{e}", nl=False, err=True)
|
|
56
|
+
return []
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def avail_versions(ctx: typer.Context) -> list[str]:
|
|
60
|
+
autocomplete_backend_init(ctx)
|
|
61
|
+
service_name = ctx.params["service_name"]
|
|
62
|
+
|
|
63
|
+
# This block prevents getting a stack trace during autocompletion
|
|
64
|
+
try:
|
|
65
|
+
version_map = fetch_service_graph(ec_backend.commands.repo)
|
|
66
|
+
svc_versions = version_map[service_name]
|
|
67
|
+
return svc_versions
|
|
68
|
+
except KeyError:
|
|
69
|
+
typer.echo(f"\n{service_name} not found", nl=False, err=True)
|
|
70
|
+
return []
|
|
71
|
+
except (ShellError, CommandError, GitError) as e:
|
|
72
|
+
typer.echo(f"\n{e}", nl=False, err=True)
|
|
73
|
+
return []
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def force_plain_completion() -> list[str]:
|
|
77
|
+
"""Forces filepath completion"""
|
|
78
|
+
return []
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def running_svc(ctx: typer.Context) -> list[str]:
|
|
82
|
+
autocomplete_backend_init(ctx)
|
|
83
|
+
try:
|
|
84
|
+
return ec_backend.commands._running_services()
|
|
85
|
+
except (CommandError, ShellError) as e:
|
|
86
|
+
typer.echo(f"\n{e}", nl=False, err=True)
|
|
87
|
+
return []
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def all_svc(ctx: typer.Context) -> list[str]:
|
|
91
|
+
autocomplete_backend_init(ctx)
|
|
92
|
+
try:
|
|
93
|
+
return ec_backend.commands._all_services()
|
|
94
|
+
except (CommandError, ShellError) as e:
|
|
95
|
+
typer.echo(f"\n{e}", nl=False, err=True)
|
|
96
|
+
return []
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage a backend for the project
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from edge_containers_cli.cmds.argo_commands import ArgoCommands
|
|
6
|
+
from edge_containers_cli.cmds.commands import Commands
|
|
7
|
+
from edge_containers_cli.cmds.k8s_commands import K8sCommands
|
|
8
|
+
from edge_containers_cli.definitions import ECBackends, ECContext
|
|
9
|
+
from edge_containers_cli.utils import public_methods
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class BackendError(Exception):
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Backend:
|
|
17
|
+
def __init__(self) -> None:
|
|
18
|
+
self._value: ECBackends | None = None
|
|
19
|
+
self._cxt: ECContext | None = None
|
|
20
|
+
self._Commands: type | None = None
|
|
21
|
+
self._commands: Commands | None = None
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def commands(self):
|
|
25
|
+
if self._commands is None:
|
|
26
|
+
raise BackendError("Backend commands not constructed")
|
|
27
|
+
else:
|
|
28
|
+
return self._commands
|
|
29
|
+
|
|
30
|
+
def set_backend(self, backend: ECBackends):
|
|
31
|
+
self._value = backend
|
|
32
|
+
if backend == ECBackends.K8S:
|
|
33
|
+
self._Commands = K8sCommands
|
|
34
|
+
elif backend == ECBackends.ARGOCD:
|
|
35
|
+
self._Commands = ArgoCommands
|
|
36
|
+
|
|
37
|
+
def set_context(self, context: ECContext):
|
|
38
|
+
"""
|
|
39
|
+
Construct the appropriate Commands class
|
|
40
|
+
"""
|
|
41
|
+
if self._Commands is None:
|
|
42
|
+
pass
|
|
43
|
+
else:
|
|
44
|
+
self._cxt = context
|
|
45
|
+
self._commands = self._Commands(context)
|
|
46
|
+
|
|
47
|
+
def get_notimplemented(self) -> list[str]:
|
|
48
|
+
notimplemented = []
|
|
49
|
+
if self._Commands is None:
|
|
50
|
+
return []
|
|
51
|
+
else:
|
|
52
|
+
for command in public_methods(self._Commands):
|
|
53
|
+
if getattr(self._Commands, command) is getattr(Commands, command):
|
|
54
|
+
notimplemented.append(command)
|
|
55
|
+
return notimplemented
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
backend = Backend()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def init_backend(set_backend: ECBackends):
|
|
62
|
+
backend.set_backend(set_backend)
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
import edge_containers_cli.globals as globals
|
|
7
|
+
from edge_containers_cli.autocomplete import (
|
|
8
|
+
all_svc,
|
|
9
|
+
avail_services,
|
|
10
|
+
avail_versions,
|
|
11
|
+
force_plain_completion,
|
|
12
|
+
running_svc,
|
|
13
|
+
)
|
|
14
|
+
from edge_containers_cli.backend import backend
|
|
15
|
+
from edge_containers_cli.cmds.commands import CommandError
|
|
16
|
+
from edge_containers_cli.definitions import ENV
|
|
17
|
+
from edge_containers_cli.git import GitError, list_all, list_instances
|
|
18
|
+
from edge_containers_cli.logging import log
|
|
19
|
+
from edge_containers_cli.shell import ShellError
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def confirmation(message: str, yes: bool):
|
|
23
|
+
typer.echo(message)
|
|
24
|
+
if not (yes or typer.confirm("Are you sure?")):
|
|
25
|
+
raise typer.Abort()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ErrorHandlingTyper(typer.Typer):
|
|
29
|
+
def __call__(self, *args, **kwargs):
|
|
30
|
+
try:
|
|
31
|
+
super().__call__(*args, **kwargs)
|
|
32
|
+
except (CommandError, ShellError, GitError) as e:
|
|
33
|
+
log.error(e)
|
|
34
|
+
typer.Exit(1)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
cli = ErrorHandlingTyper(pretty_exceptions_show_locals=False)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@cli.command()
|
|
41
|
+
def attach(
|
|
42
|
+
service_name: str = typer.Argument(
|
|
43
|
+
..., help="Name of the service to attach to", autocompletion=running_svc
|
|
44
|
+
),
|
|
45
|
+
):
|
|
46
|
+
"""
|
|
47
|
+
Attach to the console of a live service
|
|
48
|
+
"""
|
|
49
|
+
backend.commands.attach(service_name)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@cli.command()
|
|
53
|
+
def delete(
|
|
54
|
+
service_name: str = typer.Argument(
|
|
55
|
+
..., help="Name of the service to delete", autocompletion=all_svc
|
|
56
|
+
),
|
|
57
|
+
yes: bool = typer.Option(False, "-y", "--yes", help="Skip confirmation prompt"),
|
|
58
|
+
):
|
|
59
|
+
"""
|
|
60
|
+
Remove a helm deployment from the cluster
|
|
61
|
+
"""
|
|
62
|
+
confirmation(
|
|
63
|
+
f"Remove all versions of {service_name} from the target `{backend.commands.target}`",
|
|
64
|
+
yes,
|
|
65
|
+
)
|
|
66
|
+
backend.commands.delete(service_name)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@cli.command()
|
|
70
|
+
def deploy(
|
|
71
|
+
service_name: str = typer.Argument(
|
|
72
|
+
..., help="Name of the service to deploy", autocompletion=avail_services
|
|
73
|
+
),
|
|
74
|
+
version: str = typer.Argument(
|
|
75
|
+
...,
|
|
76
|
+
help="Version tag of the service to deploy",
|
|
77
|
+
autocompletion=avail_versions,
|
|
78
|
+
),
|
|
79
|
+
wait: bool = typer.Option(False, "--wait", help="Waits for readiness"),
|
|
80
|
+
yes: bool = typer.Option(False, "-y", "--yes", help="Skip confirmation prompt"),
|
|
81
|
+
args: str = typer.Option(
|
|
82
|
+
"", help="Additional args for helm or docker, 'must be quoted'"
|
|
83
|
+
),
|
|
84
|
+
):
|
|
85
|
+
"""
|
|
86
|
+
Pull an service helm chart version from the domain repo and deploy it to the cluster
|
|
87
|
+
"""
|
|
88
|
+
confirmation(
|
|
89
|
+
f"Deploy {service_name.lower()} "
|
|
90
|
+
f"of version `{version}` to target `{backend.commands.target}`",
|
|
91
|
+
yes,
|
|
92
|
+
)
|
|
93
|
+
args = args if not wait else args + " --wait"
|
|
94
|
+
backend.commands.deploy(service_name, version, args)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@cli.command()
|
|
98
|
+
def deploy_local(
|
|
99
|
+
svc_instance: Path = typer.Argument(
|
|
100
|
+
...,
|
|
101
|
+
help="folder of local service definition",
|
|
102
|
+
exists=True,
|
|
103
|
+
file_okay=False,
|
|
104
|
+
resolve_path=True,
|
|
105
|
+
autocompletion=force_plain_completion,
|
|
106
|
+
),
|
|
107
|
+
yes: bool = typer.Option(False, "-y", "--yes", help="Skip confirmation prompt"),
|
|
108
|
+
args: str = typer.Option("", help="Additional args for helm, 'must be quoted'"),
|
|
109
|
+
):
|
|
110
|
+
"""
|
|
111
|
+
Deploy a local service helm chart directly to the cluster with dated beta version
|
|
112
|
+
"""
|
|
113
|
+
confirmation(
|
|
114
|
+
f"Deploy local {svc_instance.name.lower()} "
|
|
115
|
+
f"from {svc_instance} to target `{backend.commands.target}`",
|
|
116
|
+
yes,
|
|
117
|
+
)
|
|
118
|
+
backend.commands.deploy_local(svc_instance, args)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@cli.command()
|
|
122
|
+
def env():
|
|
123
|
+
"""List all relevant environment variables"""
|
|
124
|
+
for var in ENV:
|
|
125
|
+
print(f"{var.value}={os.environ.get(var.value, 'Not Defined')}")
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@cli.command()
|
|
129
|
+
def exec(
|
|
130
|
+
service_name: str = typer.Argument(
|
|
131
|
+
...,
|
|
132
|
+
help="Name of the service container to run in",
|
|
133
|
+
autocompletion=running_svc,
|
|
134
|
+
),
|
|
135
|
+
):
|
|
136
|
+
"""Execute a bash prompt in a running container"""
|
|
137
|
+
backend.commands.exec(service_name)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@cli.command()
|
|
141
|
+
def instances(
|
|
142
|
+
service_name: str = typer.Argument(
|
|
143
|
+
..., help="Name of the service to inspect", autocompletion=avail_services
|
|
144
|
+
),
|
|
145
|
+
):
|
|
146
|
+
"""List all versions of the specified service in the repository"""
|
|
147
|
+
print(
|
|
148
|
+
list_instances(
|
|
149
|
+
service_name,
|
|
150
|
+
backend.commands.repo,
|
|
151
|
+
Path(globals.SERVICES_DIR),
|
|
152
|
+
shared=[globals.SHARED_VALUES],
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@cli.command()
|
|
158
|
+
def list():
|
|
159
|
+
"""List all services available in the service repository"""
|
|
160
|
+
print(
|
|
161
|
+
list_all(
|
|
162
|
+
backend.commands.repo,
|
|
163
|
+
Path(globals.SERVICES_DIR),
|
|
164
|
+
shared=[globals.SHARED_VALUES],
|
|
165
|
+
)
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
@cli.command()
|
|
170
|
+
def log_history(
|
|
171
|
+
service_name: str = typer.Argument(
|
|
172
|
+
...,
|
|
173
|
+
help="Name of the service to inspect",
|
|
174
|
+
autocompletion=all_svc,
|
|
175
|
+
),
|
|
176
|
+
):
|
|
177
|
+
"""Open historical logs for an service"""
|
|
178
|
+
backend.commands.log_history(service_name)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@cli.command()
|
|
182
|
+
def logs(
|
|
183
|
+
service_name: str = typer.Argument(
|
|
184
|
+
..., help="Name of the service to inspect", autocompletion=running_svc
|
|
185
|
+
),
|
|
186
|
+
prev: bool = typer.Option(
|
|
187
|
+
False,
|
|
188
|
+
"--previous",
|
|
189
|
+
"-p",
|
|
190
|
+
help="Show log from the previous instance of the service",
|
|
191
|
+
),
|
|
192
|
+
):
|
|
193
|
+
"""Show logs for current and previous instances of an service"""
|
|
194
|
+
backend.commands.logs(service_name, prev)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@cli.command()
|
|
198
|
+
def monitor(
|
|
199
|
+
running_only: bool = typer.Option(
|
|
200
|
+
False, "-r", "--running-only", help="list only services that are running"
|
|
201
|
+
),
|
|
202
|
+
):
|
|
203
|
+
"""Open monitor TUI."""
|
|
204
|
+
from edge_containers_cli.cmds.monitor import (
|
|
205
|
+
MonitorApp, # Lazy import for performace
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
app = MonitorApp(backend.commands, running_only)
|
|
209
|
+
app.run()
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@cli.command()
|
|
213
|
+
def ps(
|
|
214
|
+
running_only: bool = typer.Option(
|
|
215
|
+
False, "-r", "--running-only", help="list only services that are running"
|
|
216
|
+
),
|
|
217
|
+
):
|
|
218
|
+
"""List the services running in the current target"""
|
|
219
|
+
backend.commands.ps(running_only)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@cli.command()
|
|
223
|
+
def restart(
|
|
224
|
+
service_name: str = typer.Argument(
|
|
225
|
+
..., help="Name of the container to restart", autocompletion=running_svc
|
|
226
|
+
),
|
|
227
|
+
):
|
|
228
|
+
"""Restart a service"""
|
|
229
|
+
backend.commands.restart(service_name)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
@cli.command()
|
|
233
|
+
def start(
|
|
234
|
+
service_name: str = typer.Argument(
|
|
235
|
+
..., help="Name of the service container to start", autocompletion=all_svc
|
|
236
|
+
),
|
|
237
|
+
):
|
|
238
|
+
"""Start a service"""
|
|
239
|
+
backend.commands.start(service_name)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
@cli.command()
|
|
243
|
+
def stop(
|
|
244
|
+
service_name: str = typer.Argument(
|
|
245
|
+
...,
|
|
246
|
+
help="Name of the service container to stop",
|
|
247
|
+
autocompletion=running_svc,
|
|
248
|
+
),
|
|
249
|
+
):
|
|
250
|
+
"""Stop a service"""
|
|
251
|
+
backend.commands.stop(service_name)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
@cli.command()
|
|
255
|
+
def template(
|
|
256
|
+
svc_instance: Path = typer.Argument(
|
|
257
|
+
...,
|
|
258
|
+
help="folder of local service definition",
|
|
259
|
+
exists=True,
|
|
260
|
+
file_okay=False,
|
|
261
|
+
resolve_path=True,
|
|
262
|
+
autocompletion=force_plain_completion,
|
|
263
|
+
),
|
|
264
|
+
args: str = typer.Option("", help="Additional args for helm, 'must be quoted'"),
|
|
265
|
+
):
|
|
266
|
+
"""
|
|
267
|
+
Print out the helm template generated from a local service instance
|
|
268
|
+
"""
|
|
269
|
+
args = f"{args} --debug"
|
|
270
|
+
backend.commands.template(svc_instance, args)
|