Skip to content

Commit

Permalink
Refactor tekton resources to accept parameters via kwargs (#2175) (#2207
Browse files Browse the repository at this point in the history
)

Changes: yaml_file, name, namespace, and client can now be
passed as part of the kwargs

Usage: Class is now capable of handling them dynamically

Signed-off-by: Geetika Kapoor <gkapoor@redhat.com>
Co-authored-by: Geetika Kapoor <13978799+geetikakay@users.noreply.github.com>
  • Loading branch information
redhat-qe-bot and geetikakay authored Nov 30, 2024
1 parent ddf027d commit 0a88bbc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 29 deletions.
14 changes: 1 addition & 13 deletions ocp_resources/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@ class Pipeline(NamespacedResource):

def __init__(
self,
name=None,
namespace=None,
tasks=None,
params=None,
final_parallel_tasks=None,
client=None,
yaml_file=None,
**kwargs,
):
"""
Args:
name (str): Name of the pipeline
namespace (str): Namespace of the pipeline
tasks (str, optional): actions to perform in pipeline
client: (DynamicClient): DynamicClient to use.
params (dict, optional): params to support pipelines.
params can be set/changed based on tasks.
example: 'spec': {'params': [{'name': 'sourceTemplateName','type': 'string','default':'openshift'},
Expand All @@ -31,12 +24,7 @@ def __init__(
tasks have completed in parallel.
spec section can't be empty. It requires at least one optional field.
"""
super().__init__(
name=name,
namespace=namespace,
client=client,
**kwargs,
)
super().__init__(**kwargs)
# TODO: Add a check for tasks when bug https://issues.redhat.com/browse/SRVKP-3019 is resolved.
self.tasks = tasks
self.params = params
Expand Down
14 changes: 1 addition & 13 deletions ocp_resources/pipelineruns.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,20 @@ class PipelineRun(NamespacedResource):

def __init__(
self,
name=None,
namespace=None,
pipelineref=None,
params=None,
service_account_name=None,
client=None,
yaml_file=None,
**kwargs,
):
"""
Args:
name (str): Name of the pipelinerun
namespace (str): Namespace of the pipelinerun
pipelineref (str): Mandatory: Base pipeline to run pipelineruns
client: (DynamicClient): DynamicClient to use.
params (dict): Optional params to add during triggering a run.
params can be set/changed based on pipelineref.
example : params={"param_name1":"param_value1", "param_name2":"param_value2"}
service_account_name (str): Optional to provide service account
"""
super().__init__(
name=name,
namespace=namespace,
client=client,
**kwargs,
)
super().__init__(**kwargs)
self.pipelineref = pipelineref
self.params = params
self.service_account_name = service_account_name
Expand Down
4 changes: 1 addition & 3 deletions ocp_resources/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def __init__(
step_template (Optional[Dict[str, Any]]): Specifies a Container step definition to use as the basis for all Steps in the Task.
sidecars (Optional[List[Dict[str, Any]]]): Specifies Sidecar containers to run alongside the Steps in the Task.
"""
super().__init__(
**kwargs,
)
super().__init__(**kwargs)
self.steps = steps
self.description = description
self.params = params
Expand Down

0 comments on commit 0a88bbc

Please sign in to comment.