langlauf-cli 0.9.2__tar.gz → 0.10.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.
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/PKG-INFO +2 -4
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/commands/upload.py +12 -40
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/errors.py +4 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/jenkins/pipelines.py +45 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/settings.py +1 -2
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/pyproject.toml +7 -4
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/LICENSE +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/README.md +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/commands/configure.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/commands/delete.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/commands/download.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/commands/status.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/history.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/jenkins/builds.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/jenkins/client.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/jenkins/stage_cache.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/main.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/output.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/ui/completion.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/ui/json_output.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/ui/pickers.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/ui/tables.py +0 -0
- {langlauf_cli-0.9.2 → langlauf_cli-0.10.0}/ll_cli/validation.py +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langlauf-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
4
4
|
Summary: A comprehensive multi-platform tool providing a consistent and easy-to-use interface to Langlauf's online services.
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Author: Langlauf
|
|
7
|
-
Requires-Python: >=3.
|
|
7
|
+
Requires-Python: >=3.14,<4.0
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
11
9
|
Classifier: Programming Language :: Python :: 3.14
|
|
12
10
|
Classifier: Programming Language :: Python :: 3.15
|
|
13
11
|
Requires-Dist: api4jenkins (>=2.1.0,<3.0.0)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""`ll-cli upload` — submit a file to the SBOMaaS endpoint for SBOM generation.
|
|
2
2
|
|
|
3
|
-
Handles the product picker (interactive prompt or auto-create
|
|
4
|
-
|
|
3
|
+
Handles the product picker (interactive prompt or auto-create through the
|
|
4
|
+
endpoint's "Create product" job) and the actual `buildWithParameters` call. After
|
|
5
5
|
submitting, the command waits for Jenkins to assign the per-product analysis
|
|
6
6
|
number (the value shown in the `Analysis Number` column of `ll-cli status`),
|
|
7
7
|
records history, and prints that number to stdout so callers can pipe it into
|
|
@@ -93,9 +93,8 @@ def _resolve_product_version(
|
|
|
93
93
|
def _ensure_jenkins_job_for_product(session: client.Session, target_product_name: str) -> Project:
|
|
94
94
|
"""Return the Jenkins job for `target_product_name`, creating it if missing.
|
|
95
95
|
|
|
96
|
-
A missing job is created by
|
|
97
|
-
|
|
98
|
-
pipeline job like the template, so it's a valid SBOM pipeline by construction.
|
|
96
|
+
A missing job is created by the endpoint's "Create product" job (see
|
|
97
|
+
`pipelines.create_product`). That job also checks the name.
|
|
99
98
|
|
|
100
99
|
An existing job is validated against session.available_pipelines —
|
|
101
100
|
if the name resolves to a job that *isn't* a valid SBOM pipeline (for example a folder or a freestyle job),
|
|
@@ -106,45 +105,19 @@ def _ensure_jenkins_job_for_product(session: client.Session, target_product_name
|
|
|
106
105
|
pipelines.assert_sbom_pipeline_exists(session, target_product_name)
|
|
107
106
|
return existing_job
|
|
108
107
|
|
|
109
|
-
template_product_name = pipelines.get_default_pipeline_name(session)
|
|
110
|
-
template_job: Project | None = session.jenkins.get_job(template_product_name)
|
|
111
|
-
if template_job is None:
|
|
112
|
-
typer.echo(
|
|
113
|
-
f"ERROR: template product '{template_product_name}' not found on "
|
|
114
|
-
f"'{session.jenkins.url}'. Set DEFAULT_PIPELINE to a valid product "
|
|
115
|
-
f"or have an admin create the product for you.",
|
|
116
|
-
err=True,
|
|
117
|
-
)
|
|
118
|
-
raise typer.Abort()
|
|
119
|
-
|
|
120
108
|
output.debug_echo(
|
|
121
109
|
f"Product '{target_product_name}' does not exist on "
|
|
122
|
-
f"'{session.jenkins.url}'. Creating it
|
|
123
|
-
f"'{template_product_name}'."
|
|
110
|
+
f"'{session.jenkins.url}'. Creating it."
|
|
124
111
|
)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
template_config_xml = template_job.handle_req("GET", "config.xml").text
|
|
131
|
-
session.jenkins.create_job(target_product_name, template_config_xml)
|
|
132
|
-
except PermissionError as err:
|
|
133
|
-
# api4jenkins re-raises Jenkins's HTTP 403 as a stdlib PermissionError.
|
|
134
|
-
# The user's Jenkins account needs Job/Create on the target folder
|
|
135
|
-
# (and Job/Read on the template) to copy. Surface that hint instead
|
|
136
|
-
# of letting the raw stack trace through.
|
|
137
|
-
typer.echo(
|
|
138
|
-
f"ERROR: Jenkins denied creating product '{target_product_name}' "
|
|
139
|
-
f"({err}). Your account needs the Job/Create permission on the "
|
|
140
|
-
f"endpoint, or have an admin create the product for you.",
|
|
141
|
-
err=True,
|
|
142
|
-
)
|
|
143
|
-
raise typer.Abort()
|
|
112
|
+
creation_console = rich.console.Console(stderr=True)
|
|
113
|
+
with creation_console.status(
|
|
114
|
+
f"Creating product '{target_product_name}'... (Ctrl-C to abort)", spinner="dots"
|
|
115
|
+
):
|
|
116
|
+
pipelines.create_product(session, target_product_name)
|
|
144
117
|
created_job: Project | None = session.jenkins.get_job(target_product_name)
|
|
145
118
|
if created_job is None:
|
|
146
119
|
typer.echo(
|
|
147
|
-
f"ERROR: Jenkins reported a successful
|
|
120
|
+
f"ERROR: Jenkins reported a successful creation but product "
|
|
148
121
|
f"'{target_product_name}' is not findable. Check Jenkins logs.",
|
|
149
122
|
err=True,
|
|
150
123
|
)
|
|
@@ -179,8 +152,7 @@ def upload(
|
|
|
179
152
|
help="Target product (Jenkins job) to upload to. Without this "
|
|
180
153
|
"flag on a TTY you'll be prompted to pick from existing products "
|
|
181
154
|
"or type a new name; on non-TTY input the flag is required. "
|
|
182
|
-
"Unknown names are created
|
|
183
|
-
"DEFAULT_PIPELINE as a template.",
|
|
155
|
+
"Unknown names are created as new products.",
|
|
184
156
|
),
|
|
185
157
|
] = None,
|
|
186
158
|
product_version: Annotated[
|
|
@@ -36,6 +36,10 @@ class PipelineNotFoundError(LlCliError):
|
|
|
36
36
|
"""The named pipeline doesn't exist or isn't a valid SBOM pipeline."""
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
class ProductNotCreatedError(LlCliError):
|
|
40
|
+
"""The endpoint did not create the product."""
|
|
41
|
+
|
|
42
|
+
|
|
39
43
|
class BuildNotFoundError(LlCliError):
|
|
40
44
|
"""No matching analysis run was found."""
|
|
41
45
|
|
|
@@ -7,6 +7,7 @@ module top to use `Pipeline` / `get_pipeline_names` while building the session.
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from dataclasses import dataclass
|
|
10
|
+
import time
|
|
10
11
|
from typing import TYPE_CHECKING, NoReturn
|
|
11
12
|
|
|
12
13
|
from api4jenkins import Jenkins as SBOMaaSEndpoint # type: ignore[import-untyped]
|
|
@@ -25,6 +26,12 @@ if TYPE_CHECKING:
|
|
|
25
26
|
GENERATE_SBOM_PARAMETER_UPLOAD_FILE = "UPLOAD_FILE"
|
|
26
27
|
GENERATE_SBOM_PARAMETER_PRODUCT_VERSION = "PRODUCT_VERSION"
|
|
27
28
|
|
|
29
|
+
# sbomaas-jenkins puts this job into Jenkins. It creates a product and checks the name.
|
|
30
|
+
# It sits in a folder, so `get_pipeline_names` does not list it as a product.
|
|
31
|
+
CREATE_PRODUCT_JOB_NAME = "_actions/Create product"
|
|
32
|
+
CREATE_PRODUCT_PARAMETER_PRODUCT_NAME = "PRODUCT_NAME"
|
|
33
|
+
CREATE_PRODUCT_POLL_INTERVAL_SECONDS = 0.5
|
|
34
|
+
|
|
28
35
|
|
|
29
36
|
@dataclass
|
|
30
37
|
class Pipeline:
|
|
@@ -52,6 +59,44 @@ def get_pipeline_names(jenkins: SBOMaaSEndpoint) -> list[Pipeline]:
|
|
|
52
59
|
return pipelines
|
|
53
60
|
|
|
54
61
|
|
|
62
|
+
def create_product(session: "Session", product_name: str) -> None:
|
|
63
|
+
"""Create the product `product_name` on the endpoint.
|
|
64
|
+
|
|
65
|
+
The endpoint's "Create product" job does the work. This blocks until that job
|
|
66
|
+
has finished. There is no time limit, as with the wait for an upload.
|
|
67
|
+
|
|
68
|
+
Raises `ProductNotCreatedError` when the endpoint has no such job, or when the
|
|
69
|
+
job refuses the name. The job writes its reason into the build's description.
|
|
70
|
+
"""
|
|
71
|
+
create_product_job: Project | None = session.jenkins.get_job(CREATE_PRODUCT_JOB_NAME)
|
|
72
|
+
if create_product_job is None:
|
|
73
|
+
raise errors.ProductNotCreatedError(
|
|
74
|
+
f"ERROR: the SBOMaaS server '{session.jenkins.url}' cannot create "
|
|
75
|
+
"products yet. It needs an update. Until then, use ll-cli 0.9.x to "
|
|
76
|
+
"create a product."
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
build_parameters = {CREATE_PRODUCT_PARAMETER_PRODUCT_NAME: product_name}
|
|
80
|
+
queued_item = create_product_job.build(**build_parameters)
|
|
81
|
+
build = queued_item.get_build()
|
|
82
|
+
while build is None:
|
|
83
|
+
time.sleep(CREATE_PRODUCT_POLL_INTERVAL_SECONDS)
|
|
84
|
+
build = queued_item.get_build()
|
|
85
|
+
|
|
86
|
+
build_state = build.api_json(tree="building,result,description")
|
|
87
|
+
while build_state["building"]:
|
|
88
|
+
time.sleep(CREATE_PRODUCT_POLL_INTERVAL_SECONDS)
|
|
89
|
+
build_state = build.api_json(tree="building,result,description")
|
|
90
|
+
|
|
91
|
+
if build_state["result"] != "SUCCESS":
|
|
92
|
+
reason = build_state["description"]
|
|
93
|
+
if reason is None:
|
|
94
|
+
reason = "the server gave no reason."
|
|
95
|
+
raise errors.ProductNotCreatedError(
|
|
96
|
+
f"ERROR: could not create product '{product_name}': {reason}"
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
|
|
55
100
|
def get_default_pipeline_name(session: "Session") -> str:
|
|
56
101
|
"""Return the pipeline name to use when no `--product` is given.
|
|
57
102
|
|
|
@@ -52,8 +52,7 @@ class Settings(BaseSettings):
|
|
|
52
52
|
|
|
53
53
|
# ---------------------------------
|
|
54
54
|
# Default product (a Jenkins pipeline/job on the SBOMaaS endpoint). Used
|
|
55
|
-
# by `ll-cli status` (no args) as the listing scope
|
|
56
|
-
# as the template that new products are copied from. Set via the
|
|
55
|
+
# by `ll-cli status` (no args) as the listing scope. Set via the
|
|
57
56
|
# `DEFAULT_PIPELINE` env var or config.env entry. If unset, the first
|
|
58
57
|
# discovered SBOM pipeline is used.
|
|
59
58
|
# ---------------------------------
|
|
@@ -11,14 +11,14 @@ dynamic = ["version", "dependencies", "classifiers", "requires-python"]
|
|
|
11
11
|
ll-cli = "ll_cli.main:app"
|
|
12
12
|
|
|
13
13
|
[tool.poetry]
|
|
14
|
-
version = "0.
|
|
14
|
+
version = "0.10.0"
|
|
15
15
|
packages = [
|
|
16
16
|
{ include = "ll_cli" },
|
|
17
17
|
{ include = "LICENSE" },
|
|
18
18
|
]
|
|
19
19
|
|
|
20
20
|
[tool.poetry.dependencies]
|
|
21
|
-
python = "^3.
|
|
21
|
+
python = "^3.14"
|
|
22
22
|
typer = ">=0.20.0,<0.26.0"
|
|
23
23
|
api4jenkins = "^2.1.0"
|
|
24
24
|
pydantic = "^2.13.4"
|
|
@@ -38,8 +38,8 @@ pytest-cov = "^7.0.0"
|
|
|
38
38
|
coverage = {extras = ["toml"], version = "^7.11.0"}
|
|
39
39
|
taskipy = "^1.14.1"
|
|
40
40
|
mypy = "^1.19.0"
|
|
41
|
-
sbomaas-jenkins = "^2.0
|
|
42
|
-
ll-sbomaas-utils = "^0.2.
|
|
41
|
+
sbomaas-jenkins = "^2.2.0"
|
|
42
|
+
ll-sbomaas-utils = "^0.2.2"
|
|
43
43
|
|
|
44
44
|
[tool.pytest.ini_options]
|
|
45
45
|
#log_cli = true
|
|
@@ -61,6 +61,9 @@ namespace_packages = true
|
|
|
61
61
|
# top-level modules inside the source folder.
|
|
62
62
|
explicit_package_bases = true
|
|
63
63
|
|
|
64
|
+
# Skip what git ignores, such as experiments/.
|
|
65
|
+
exclude_gitignore = true
|
|
66
|
+
|
|
64
67
|
# Enable pydantic's mypy plugin so that errors with pydantic models are caught
|
|
65
68
|
# as well.
|
|
66
69
|
plugins = ["pydantic.mypy"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|