Skip to content

Commit 1f4ba4f

Browse files
authored
fix: Auto-generate tekton resources (#2557)
Signed-off-by: Geetika Kapoor <[email protected]>
1 parent ad9e665 commit 1f4ba4f

File tree

5 files changed

+351
-157
lines changed

5 files changed

+351
-157
lines changed

ocp_resources/pipeline.py

Lines changed: 75 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,91 @@
1-
# API reference: https://tekton.dev/docs/pipelines/pipelines/
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
22

3-
from ocp_resources.resource import MissingRequiredArgumentError, NamespacedResource
3+
4+
from typing import Any
5+
from ocp_resources.resource import NamespacedResource
46

57

68
class Pipeline(NamespacedResource):
7-
api_group = NamespacedResource.ApiGroup.TEKTON_DEV
9+
"""
10+
Pipeline describes a list of Tasks to execute. It expresses how outputs
11+
of tasks feed into inputs of subsequent tasks.
12+
"""
13+
14+
api_group: str = NamespacedResource.ApiGroup.TEKTON_DEV
815

916
def __init__(
1017
self,
11-
tasks=None,
12-
params=None,
13-
final_parallel_tasks=None,
14-
**kwargs,
15-
):
16-
"""
18+
description: str | None = None,
19+
display_name: str | None = None,
20+
finally_: list[Any] | None = None,
21+
params: list[Any] | None = None,
22+
results: list[Any] | None = None,
23+
tasks: list[Any] | None = None,
24+
workspaces: list[Any] | None = None,
25+
**kwargs: Any,
26+
) -> None:
27+
r"""
1728
Args:
18-
tasks (str, optional): actions to perform in pipeline
19-
params (dict, optional): params to support pipelines.
20-
params can be set/changed based on tasks.
21-
example: 'spec': {'params': [{'name': 'sourceTemplateName','type': 'string','default':'openshift'},
22-
{'name': 'sourceTemplateNamespace', 'type':'string', 'description': 'Namespace pf template'}]}
23-
final_parallel_tasks (list, optional): a list of one or more to be executed in parallel after all other
24-
tasks have completed in parallel.
25-
spec section can't be empty. It requires at least one optional field.
29+
description (str): Description is a user-facing description of the pipeline that may be
30+
used to populate a UI.
31+
32+
display_name (str): DisplayName is a user-facing name of the pipeline that may be used to
33+
populate a UI.
34+
35+
finally_ (list[Any]): Finally declares the list of Tasks that execute just before leaving
36+
the Pipeline i.e. either after all Tasks are finished executing
37+
successfully or after a failure which would result in ending the
38+
Pipeline
39+
40+
Note: Parameter renamed from &#39;finally&#39; to avoid Python keyword conflict.
41+
params (list[Any]): Params declares a list of input parameters that must be supplied when
42+
this Pipeline is run.
43+
44+
results (list[Any]): Results are values that this pipeline can output once run
45+
46+
tasks (list[Any]): Tasks declares the graph of Tasks that execute when this Pipeline is
47+
run.
48+
49+
workspaces (list[Any]): Workspaces declares a set of named workspaces that are expected to be
50+
provided by a PipelineRun.
51+
2652
"""
2753
super().__init__(**kwargs)
28-
# TODO: Add a check for tasks when bug https://issues.redhat.com/browse/SRVKP-3019 is resolved.
29-
self.tasks = tasks
54+
55+
self.description = description
56+
self.display_name = display_name
57+
self.finally_ = finally_
3058
self.params = params
31-
self.final_parallel_tasks = final_parallel_tasks
59+
self.results = results
60+
self.tasks = tasks
61+
self.workspaces = workspaces
3262

3363
def to_dict(self) -> None:
3464
super().to_dict()
35-
if not self.kind_dict and not self.yaml_file:
36-
if not (self.tasks or self.params or self.final_parallel_tasks):
37-
raise MissingRequiredArgumentError(argument="'tasks' or 'params' or 'final_parallel_tasks'")
3865

66+
if not self.kind_dict and not self.yaml_file:
3967
self.res["spec"] = {}
40-
if self.params:
41-
self.res["spec"]["params"] = self.params
42-
if self.tasks:
43-
self.res["spec"]["tasks"] = self.tasks
44-
if self.final_parallel_tasks:
45-
self.res["spec"]["finally"] = self.final_parallel_tasks
68+
_spec = self.res["spec"]
69+
70+
if self.description is not None:
71+
_spec["description"] = self.description
72+
73+
if self.display_name is not None:
74+
_spec["displayName"] = self.display_name
75+
76+
if self.finally_ is not None:
77+
_spec["finally"] = self.finally_
78+
79+
if self.params is not None:
80+
_spec["params"] = self.params
81+
82+
if self.results is not None:
83+
_spec["results"] = self.results
84+
85+
if self.tasks is not None:
86+
_spec["tasks"] = self.tasks
87+
88+
if self.workspaces is not None:
89+
_spec["workspaces"] = self.workspaces
90+
91+
# End of generated code

ocp_resources/pipeline_run.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2+
3+
4+
from typing import Any
5+
from ocp_resources.resource import NamespacedResource
6+
7+
8+
class PipelineRun(NamespacedResource):
9+
"""
10+
PipelineRun represents a single execution of a Pipeline. PipelineRuns are how
11+
the graph of Tasks declared in a Pipeline are executed; they specify inputs
12+
to Pipelines such as parameter values and capture operational aspects of the
13+
Tasks execution such as service account and tolerations. Creating a
14+
PipelineRun creates TaskRuns for Tasks in the referenced Pipeline.
15+
"""
16+
17+
api_group: str = NamespacedResource.ApiGroup.TEKTON_DEV
18+
19+
def __init__(
20+
self,
21+
params: list[Any] | None = None,
22+
pipeline_ref: dict[str, Any] | None = None,
23+
pipeline_spec: Any | None = None,
24+
task_run_specs: list[Any] | None = None,
25+
task_run_template: dict[str, Any] | None = None,
26+
timeouts: dict[str, Any] | None = None,
27+
workspaces: list[Any] | None = None,
28+
**kwargs: Any,
29+
) -> None:
30+
r"""
31+
Args:
32+
params (list[Any]): Params is a list of parameter names and values.
33+
34+
pipeline_ref (dict[str, Any]): PipelineRef can be used to refer to a specific instance of a Pipeline.
35+
36+
pipeline_spec (Any): Specifying PipelineSpec can be disabled by setting `disable-inline-
37+
spec` feature flag. See Pipeline.spec (API version: tekton.dev/v1)
38+
39+
task_run_specs (list[Any]): TaskRunSpecs holds a set of runtime specs
40+
41+
task_run_template (dict[str, Any]): TaskRunTemplate represent template of taskrun
42+
43+
timeouts (dict[str, Any]): Time after which the Pipeline times out. Currently three keys are
44+
accepted in the map pipeline, tasks and finally with
45+
Timeouts.pipeline >= Timeouts.tasks + Timeouts.finally
46+
47+
workspaces (list[Any]): Workspaces holds a set of workspace bindings that must match names
48+
with those declared in the pipeline.
49+
50+
"""
51+
super().__init__(**kwargs)
52+
53+
self.params = params
54+
self.pipeline_ref = pipeline_ref
55+
self.pipeline_spec = pipeline_spec
56+
self.task_run_specs = task_run_specs
57+
self.task_run_template = task_run_template
58+
self.timeouts = timeouts
59+
self.workspaces = workspaces
60+
61+
def to_dict(self) -> None:
62+
super().to_dict()
63+
64+
if not self.kind_dict and not self.yaml_file:
65+
self.res["spec"] = {}
66+
_spec = self.res["spec"]
67+
68+
if self.params is not None:
69+
_spec["params"] = self.params
70+
71+
if self.pipeline_ref is not None:
72+
_spec["pipelineRef"] = self.pipeline_ref
73+
74+
if self.pipeline_spec is not None:
75+
_spec["pipelineSpec"] = self.pipeline_spec
76+
77+
if self.task_run_specs is not None:
78+
_spec["taskRunSpecs"] = self.task_run_specs
79+
80+
if self.task_run_template is not None:
81+
_spec["taskRunTemplate"] = self.task_run_template
82+
83+
if self.timeouts is not None:
84+
_spec["timeouts"] = self.timeouts
85+
86+
if self.workspaces is not None:
87+
_spec["workspaces"] = self.workspaces
88+
89+
# End of generated code

ocp_resources/pipelineruns.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)