99from cdevents .cli .utils import add_disclaimer_text , print_function_args
1010from cdevents .cli .cdevents_command import CDeventsCommand
1111
12+ from cdevents .core .events import Events
13+ from cdevents .core import event_type
14+
1215# pylint: disable=unused-argument
1316def common_pipelinerun_options (function ):
1417 """Decorator for common cli options for pipelinerun."""
@@ -70,17 +73,10 @@ def started(
7073 data : List [str ] = None ,
7174):
7275 print_function_args ()
73- pipeline_run_started_event_v1 = "cd.pipelinerun.started.v1"
74- extensions = {
75- "pipelinerunid" : id ,
76- "pipelinerunname" : name ,
77- "pipelinerunstatus" : status ,
78- "pipelinerunurl" : url ,
79- "pipelinerunerrors" : errors ,
80- }
81-
76+ e = Events ()
77+ new_event = e .create_pipelinerun_event (event_type .PipelineRunStartedEventV1 , id , name , status , url , errors , data )
8278 cdevents_command = CDeventsCommand ()
83- cdevents_command .run (pipeline_run_started_event_v1 , extensions , data )
79+ cdevents_command .run (new_event )
8480
8581
8682@click .command (help = add_disclaimer_text ("PipelineRun Finished CloudEvent." ))
@@ -94,17 +90,10 @@ def finished(
9490 data : List [str ] = None ,
9591):
9692 print_function_args ()
97- pipeline_run_finished_event_v1 = "cd.pipelinerun.finished.v1"
98- extensions = {
99- "pipelinerunid" : id ,
100- "pipelinerunname" : name ,
101- "pipelinerunstatus" : status ,
102- "pipelinerunurl" : url ,
103- "pipelinerunerrors" : errors ,
104- }
105-
93+ e = Events ()
94+ new_event = e .create_pipelinerun_event (event_type .PipelineRunFinishedEventV1 , id , name , status , url , errors , data )
10695 cdevents_command = CDeventsCommand ()
107- cdevents_command .run (pipeline_run_finished_event_v1 , extensions , data )
96+ cdevents_command .run (new_event )
10897
10998@click .command (help = add_disclaimer_text ("PipelineRun Queued CloudEvent." ))
11099@common_pipelinerun_options
@@ -117,14 +106,8 @@ def queued(
117106 data : List [str ] = None ,
118107):
119108 print_function_args ()
120- pipeline_run_queued_event_v1 = "cd.pipelinerun.queued.v1"
121- extensions = {
122- "pipelinerunid" : id ,
123- "pipelinerunname" : name ,
124- "pipelinerunstatus" : status ,
125- "pipelinerunurl" : url ,
126- "pipelinerunerrors" : errors ,
127- }
128-
109+ e = Events ()
110+ new_event = e .create_pipelinerun_event (event_type .PipelineRunQueuedEventV1 , id , name , status , url , errors , data )
129111 cdevents_command = CDeventsCommand ()
130- cdevents_command .run (pipeline_run_queued_event_v1 , extensions , data )
112+ cdevents_command .run (new_event )
113+
0 commit comments