toolforge-components-cli 0.0.8__tar.gz → 0.0.11__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.
- {toolforge_components_cli-0.0.8 → toolforge_components_cli-0.0.11}/PKG-INFO +1 -1
- {toolforge_components_cli-0.0.8 → toolforge_components_cli-0.0.11}/pyproject.toml +1 -1
- {toolforge_components_cli-0.0.8 → toolforge_components_cli-0.0.11}/toolforge_components_cli/cli.py +31 -4
- {toolforge_components_cli-0.0.8 → toolforge_components_cli-0.0.11}/LICENSE +0 -0
- {toolforge_components_cli-0.0.8 → toolforge_components_cli-0.0.11}/README.md +0 -0
- {toolforge_components_cli-0.0.8 → toolforge_components_cli-0.0.11}/toolforge_components_cli/__init__.py +0 -0
- {toolforge_components_cli-0.0.8 → toolforge_components_cli-0.0.11}/toolforge_components_cli/components.py +0 -0
- {toolforge_components_cli-0.0.8 → toolforge_components_cli-0.0.11}/toolforge_components_cli/config.py +0 -0
{toolforge_components_cli-0.0.8 → toolforge_components_cli-0.0.11}/toolforge_components_cli/cli.py
RENAMED
|
@@ -6,6 +6,7 @@ import logging
|
|
|
6
6
|
import os
|
|
7
7
|
import subprocess
|
|
8
8
|
import sys
|
|
9
|
+
import textwrap
|
|
9
10
|
from textwrap import indent
|
|
10
11
|
from typing import Any
|
|
11
12
|
|
|
@@ -39,6 +40,9 @@ TOKEN_EXISTS_MSG = """A valid deployment token already exists. You can:
|
|
|
39
40
|
- Use 'deploy-token show' to see the current token
|
|
40
41
|
- Use 'deploy-token refresh' to create a new token (this will invalidate the current one)
|
|
41
42
|
- Use 'deploy-token delete' to remove the current token"""
|
|
43
|
+
# this seems to be enough to show the 'job <> is already up to date' message for most jobs and not too long to be
|
|
44
|
+
# too annoying
|
|
45
|
+
LONG_STATUS_WIDTH = 45
|
|
42
46
|
|
|
43
47
|
|
|
44
48
|
def handle_error(e: Exception, debug: bool = False) -> None:
|
|
@@ -110,7 +114,7 @@ def _display_deployment(deployment_data: dict, as_json: bool, prefix: str = "")
|
|
|
110
114
|
click.echo("\n" + click.style("Builds:", bold=True))
|
|
111
115
|
for component, build in deployment_data["builds"].items():
|
|
112
116
|
click.echo(
|
|
113
|
-
f" {component}({_format_status(build['build_status'])}): {build['build_id']}"
|
|
117
|
+
f" {component}({_format_status(build['build_status'])}): id:{build['build_id']} {build.get('build_long_status', '')}"
|
|
114
118
|
)
|
|
115
119
|
|
|
116
120
|
if deployment_data.get("runs"):
|
|
@@ -205,6 +209,23 @@ def config_show(ctx, as_json: bool) -> None:
|
|
|
205
209
|
_display_config(response.get("data", {}), as_json)
|
|
206
210
|
|
|
207
211
|
|
|
212
|
+
@config.command(
|
|
213
|
+
name="generate",
|
|
214
|
+
help="Generate an example tool configuration from the existing jobs if possible.",
|
|
215
|
+
)
|
|
216
|
+
@click.option(
|
|
217
|
+
"--json",
|
|
218
|
+
"as_json",
|
|
219
|
+
is_flag=True,
|
|
220
|
+
help="If set, will output in JSON format",
|
|
221
|
+
)
|
|
222
|
+
@click.pass_context
|
|
223
|
+
def config_generate(ctx, as_json: bool) -> None:
|
|
224
|
+
components_client = ctx.obj["components_client"]
|
|
225
|
+
response = components_client.get("/config/generate", display_messages=(not as_json))
|
|
226
|
+
_display_config(response.get("data", {}), as_json)
|
|
227
|
+
|
|
228
|
+
|
|
208
229
|
@config.command(name="delete", help="Delete the tool's configuration.")
|
|
209
230
|
@click.option(
|
|
210
231
|
"--json",
|
|
@@ -418,8 +439,12 @@ def _format_headers(headers: list[str]) -> list[str]:
|
|
|
418
439
|
def _format_builds(builds: dict[str, dict[str, Any]]) -> str:
|
|
419
440
|
builds_strings: list[str] = []
|
|
420
441
|
for component_name, build_info in builds.items():
|
|
442
|
+
short_status = _format_status(build_info["build_status"])
|
|
443
|
+
long_status = textwrap.shorten(
|
|
444
|
+
build_info.get("build_long_status", ""), width=LONG_STATUS_WIDTH
|
|
445
|
+
)
|
|
421
446
|
builds_strings.append(
|
|
422
|
-
f"{component_name}({
|
|
447
|
+
f"{component_name}({short_status}): id:{build_info['build_id']} {long_status}"
|
|
423
448
|
)
|
|
424
449
|
return "\n".join(builds_strings)
|
|
425
450
|
|
|
@@ -427,9 +452,11 @@ def _format_builds(builds: dict[str, dict[str, Any]]) -> str:
|
|
|
427
452
|
def _format_runs(runs: dict[str, dict[str, Any]]) -> str:
|
|
428
453
|
runs_strings: list[str] = []
|
|
429
454
|
for component_name, run_info in runs.items():
|
|
430
|
-
|
|
431
|
-
|
|
455
|
+
short_status = _format_status(run_info["run_status"])
|
|
456
|
+
long_status = textwrap.shorten(
|
|
457
|
+
run_info.get("run_long_status", ""), width=LONG_STATUS_WIDTH
|
|
432
458
|
)
|
|
459
|
+
runs_strings.append(f"{component_name}({short_status}): {long_status}")
|
|
433
460
|
return "\n".join(runs_strings)
|
|
434
461
|
|
|
435
462
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|