toolforge-components-cli 0.0.17__tar.gz → 0.0.18__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolforge-components-cli
3
- Version: 0.0.17
3
+ Version: 0.0.18
4
4
  Summary: Toolforge components client
5
5
  License: GPLv3
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "toolforge-components-cli"
3
- version = "0.0.17"
3
+ version = "0.0.18"
4
4
  description = "Toolforge components client"
5
5
  authors = ["Slavina Stefanova <sstefanova@wikimedia.org>"]
6
6
  license = "GPLv3"
@@ -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"))
@@ -394,6 +400,11 @@ def deployment():
394
400
  "(ex. delete + create the continuous job)"
395
401
  ),
396
402
  )
403
+ @click.option(
404
+ "--description",
405
+ type=str,
406
+ help="Human-readable context describing what is being deployed and why.",
407
+ )
397
408
  @click.option(
398
409
  "--json",
399
410
  "as_json",
@@ -401,7 +412,13 @@ def deployment():
401
412
  help="If set, will output in JSON format",
402
413
  )
403
414
  @click.pass_context
404
- def deployment_create(ctx, force_build: bool, force_run: bool, as_json: bool) -> None:
415
+ def deployment_create(
416
+ ctx,
417
+ force_build: bool,
418
+ force_run: bool,
419
+ description: str | None,
420
+ as_json: bool,
421
+ ) -> None:
405
422
  components_client = ctx.obj["components_client"]
406
423
  display_messages = not as_json
407
424
 
@@ -411,9 +428,14 @@ def deployment_create(ctx, force_build: bool, force_run: bool, as_json: bool) ->
411
428
  if force_run:
412
429
  query_params["force-run"] = "true"
413
430
 
414
- response = components_client.post(
415
- "/deployment", params=query_params, display_messages=display_messages
416
- )
431
+ request_kwargs: dict[str, Any] = {
432
+ "params": query_params,
433
+ "display_messages": display_messages,
434
+ }
435
+ if description is not None:
436
+ request_kwargs["json"] = {"description": description}
437
+
438
+ response = components_client.post("/deployment", **request_kwargs)
417
439
 
418
440
  if as_json:
419
441
  click.echo(json.dumps(response, indent=4))
@@ -421,6 +443,8 @@ def deployment_create(ctx, force_build: bool, force_run: bool, as_json: bool) ->
421
443
  deployment_data = response.get("data", {})
422
444
  click.echo(f"Deployment ID: {deployment_data.get('deploy_id')}")
423
445
  click.echo(f"Created: {deployment_data.get('creation_time')}")
446
+ if deployment_data.get("description"):
447
+ click.echo(f"Description: {deployment_data['description']}")
424
448
  if deployment_data.get("builds"):
425
449
  click.echo("\nBuilds:")
426
450
  for component, build in deployment_data["builds"].items():
@@ -499,6 +523,9 @@ def deployment_list(ctx, as_json: bool) -> None:
499
523
  [
500
524
  deployment["deploy_id"],
501
525
  deployment["creation_time"],
526
+ textwrap.shorten(
527
+ deployment.get("description", ""), width=DESCRIPTION_WIDTH
528
+ ),
502
529
  _format_status(deployment.get("status", "unknown")),
503
530
  _format_builds(deployment.get("builds", {})),
504
531
  _format_runs(deployment.get("runs", {})),
@@ -509,7 +536,7 @@ def deployment_list(ctx, as_json: bool) -> None:
509
536
  tabulate(
510
537
  formatted_deployments,
511
538
  headers=_format_headers(
512
- ["ID", "Creation time", "Status", "Builds", "Runs"]
539
+ ["ID", "Creation time", "Description", "Status", "Builds", "Runs"]
513
540
  ),
514
541
  )
515
542
  )