toolforge-components-cli 0.0.17__tar.gz → 0.0.19__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.17 → toolforge_components_cli-0.0.19}/PKG-INFO +1 -1
- {toolforge_components_cli-0.0.17 → toolforge_components_cli-0.0.19}/pyproject.toml +1 -1
- {toolforge_components_cli-0.0.17 → toolforge_components_cli-0.0.19}/toolforge_components_cli/cli.py +41 -12
- {toolforge_components_cli-0.0.17 → toolforge_components_cli-0.0.19}/LICENSE +0 -0
- {toolforge_components_cli-0.0.17 → toolforge_components_cli-0.0.19}/README.md +0 -0
- {toolforge_components_cli-0.0.17 → toolforge_components_cli-0.0.19}/toolforge_components_cli/__init__.py +0 -0
- {toolforge_components_cli-0.0.17 → toolforge_components_cli-0.0.19}/toolforge_components_cli/components.py +0 -0
- {toolforge_components_cli-0.0.17 → toolforge_components_cli-0.0.19}/toolforge_components_cli/config.py +0 -0
{toolforge_components_cli-0.0.17 → toolforge_components_cli-0.0.19}/toolforge_components_cli/cli.py
RENAMED
|
@@ -42,6 +42,8 @@ TOKEN_EXISTS_MSG = """A valid deployment token already exists. You can:
|
|
|
42
42
|
# this seems to be enough to show the 'job <> is already up to date' message for most jobs and not too long to be
|
|
43
43
|
# too annoying
|
|
44
44
|
LONG_STATUS_WIDTH = 45
|
|
45
|
+
# Keep freeform descriptions from making the deployment list excessively wide.
|
|
46
|
+
DESCRIPTION_WIDTH = 45
|
|
45
47
|
|
|
46
48
|
|
|
47
49
|
def handle_error(e: Exception, debug: bool = False) -> None:
|
|
@@ -100,6 +102,10 @@ def _display_deployment(deployment_data: dict, as_json: bool, prefix: str = "")
|
|
|
100
102
|
click.echo(
|
|
101
103
|
click.style("Created: ", bold=True) + deployment_data["creation_time"]
|
|
102
104
|
)
|
|
105
|
+
if deployment_data.get("description"):
|
|
106
|
+
click.echo(
|
|
107
|
+
click.style("Description: ", bold=True) + deployment_data["description"]
|
|
108
|
+
)
|
|
103
109
|
click.echo(
|
|
104
110
|
click.style("Status: ", bold=True)
|
|
105
111
|
+ _format_status(deployment_data.get("status", "unknown"))
|
|
@@ -182,13 +188,15 @@ def config_create(ctx, config: TextIO | None, as_json: bool) -> None:
|
|
|
182
188
|
components_client = ctx.obj["components_client"]
|
|
183
189
|
display_messages = not as_json
|
|
184
190
|
|
|
185
|
-
if config is None:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
config_data = yaml.safe_load(
|
|
191
|
+
if config is None and _should_prompt():
|
|
192
|
+
click.echo(MISSING_CONFIG_MSG, err=True)
|
|
193
|
+
sys.exit(1)
|
|
194
|
+
|
|
195
|
+
config_source = config if config is not None else sys.stdin
|
|
196
|
+
try:
|
|
197
|
+
config_data = yaml.safe_load(config_source)
|
|
198
|
+
except yaml.YAMLError as e:
|
|
199
|
+
raise ToolforgeUserError(f"Invalid YAML configuration: {e}") from e
|
|
192
200
|
|
|
193
201
|
response = components_client.post(
|
|
194
202
|
"/config", json=config_data, display_messages=display_messages
|
|
@@ -394,6 +402,11 @@ def deployment():
|
|
|
394
402
|
"(ex. delete + create the continuous job)"
|
|
395
403
|
),
|
|
396
404
|
)
|
|
405
|
+
@click.option(
|
|
406
|
+
"--description",
|
|
407
|
+
type=str,
|
|
408
|
+
help="Human-readable context describing what is being deployed and why.",
|
|
409
|
+
)
|
|
397
410
|
@click.option(
|
|
398
411
|
"--json",
|
|
399
412
|
"as_json",
|
|
@@ -401,7 +414,13 @@ def deployment():
|
|
|
401
414
|
help="If set, will output in JSON format",
|
|
402
415
|
)
|
|
403
416
|
@click.pass_context
|
|
404
|
-
def deployment_create(
|
|
417
|
+
def deployment_create(
|
|
418
|
+
ctx,
|
|
419
|
+
force_build: bool,
|
|
420
|
+
force_run: bool,
|
|
421
|
+
description: str | None,
|
|
422
|
+
as_json: bool,
|
|
423
|
+
) -> None:
|
|
405
424
|
components_client = ctx.obj["components_client"]
|
|
406
425
|
display_messages = not as_json
|
|
407
426
|
|
|
@@ -411,9 +430,14 @@ def deployment_create(ctx, force_build: bool, force_run: bool, as_json: bool) ->
|
|
|
411
430
|
if force_run:
|
|
412
431
|
query_params["force-run"] = "true"
|
|
413
432
|
|
|
414
|
-
|
|
415
|
-
"
|
|
416
|
-
|
|
433
|
+
request_kwargs: dict[str, Any] = {
|
|
434
|
+
"params": query_params,
|
|
435
|
+
"display_messages": display_messages,
|
|
436
|
+
}
|
|
437
|
+
if description is not None:
|
|
438
|
+
request_kwargs["json"] = {"description": description}
|
|
439
|
+
|
|
440
|
+
response = components_client.post("/deployment", **request_kwargs)
|
|
417
441
|
|
|
418
442
|
if as_json:
|
|
419
443
|
click.echo(json.dumps(response, indent=4))
|
|
@@ -421,6 +445,8 @@ def deployment_create(ctx, force_build: bool, force_run: bool, as_json: bool) ->
|
|
|
421
445
|
deployment_data = response.get("data", {})
|
|
422
446
|
click.echo(f"Deployment ID: {deployment_data.get('deploy_id')}")
|
|
423
447
|
click.echo(f"Created: {deployment_data.get('creation_time')}")
|
|
448
|
+
if deployment_data.get("description"):
|
|
449
|
+
click.echo(f"Description: {deployment_data['description']}")
|
|
424
450
|
if deployment_data.get("builds"):
|
|
425
451
|
click.echo("\nBuilds:")
|
|
426
452
|
for component, build in deployment_data["builds"].items():
|
|
@@ -499,6 +525,9 @@ def deployment_list(ctx, as_json: bool) -> None:
|
|
|
499
525
|
[
|
|
500
526
|
deployment["deploy_id"],
|
|
501
527
|
deployment["creation_time"],
|
|
528
|
+
textwrap.shorten(
|
|
529
|
+
deployment.get("description", ""), width=DESCRIPTION_WIDTH
|
|
530
|
+
),
|
|
502
531
|
_format_status(deployment.get("status", "unknown")),
|
|
503
532
|
_format_builds(deployment.get("builds", {})),
|
|
504
533
|
_format_runs(deployment.get("runs", {})),
|
|
@@ -509,7 +538,7 @@ def deployment_list(ctx, as_json: bool) -> None:
|
|
|
509
538
|
tabulate(
|
|
510
539
|
formatted_deployments,
|
|
511
540
|
headers=_format_headers(
|
|
512
|
-
["ID", "Creation time", "Status", "Builds", "Runs"]
|
|
541
|
+
["ID", "Creation time", "Description", "Status", "Builds", "Runs"]
|
|
513
542
|
),
|
|
514
543
|
)
|
|
515
544
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|