|
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 |
2 | 2 |
|
3 | | -from ocp_resources.resource import MissingRequiredArgumentError, NamespacedResource |
| 3 | + |
| 4 | +from typing import Any |
| 5 | +from ocp_resources.resource import NamespacedResource |
4 | 6 |
|
5 | 7 |
|
6 | 8 | 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 |
8 | 15 |
|
9 | 16 | def __init__( |
10 | 17 | 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""" |
17 | 28 | 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 'finally' 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 | +
|
26 | 52 | """ |
27 | 53 | 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_ |
30 | 58 | self.params = params |
31 | | - self.final_parallel_tasks = final_parallel_tasks |
| 59 | + self.results = results |
| 60 | + self.tasks = tasks |
| 61 | + self.workspaces = workspaces |
32 | 62 |
|
33 | 63 | def to_dict(self) -> None: |
34 | 64 | 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'") |
38 | 65 |
|
| 66 | + if not self.kind_dict and not self.yaml_file: |
39 | 67 | 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 |
0 commit comments