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
12+ from cdevents .core .build import Build , BuildType
1413
1514# pylint: disable=unused-argument
1615def common_build_options (function ):
@@ -58,10 +57,10 @@ def started(
5857 data : List [str ] = None ,
5958):
6059 print_function_args ()
61- e = Events ( )
62- new_event = e . create_build_event ( event_type . BuildStartedEventV1 , id , name , artifact , data )
60+ build = Build ( build_type = BuildType . BuildStartedEventV1 , id = id , name = name , artifact = artifact )
61+ build_event = build . create_event ( data )
6362 cdevents_command = CDeventsCommand ()
64- cdevents_command .run (new_event )
63+ cdevents_command .run (build_event )
6564
6665@click .command (help = add_disclaimer_text ("Build Finished CloudEvent." ))
6766@common_build_options
@@ -72,10 +71,10 @@ def finished(
7271 data : List [str ] = None ,
7372):
7473 print_function_args ()
75- e = Events ( )
76- new_event = e . create_build_event ( event_type . BuildFinishedEventV1 , id , name , artifact , data )
74+ build = Build ( build_type = BuildType . BuildFinishedEventV1 , id = id , name = name , artifact = artifact )
75+ build_event = build . create_event ( data )
7776 cdevents_command = CDeventsCommand ()
78- cdevents_command .run (new_event )
77+ cdevents_command .run (build_event )
7978
8079@click .command (help = add_disclaimer_text ("PipelineRun Queued CloudEvent." ))
8180@common_build_options
@@ -86,7 +85,7 @@ def queued(
8685 data : List [str ] = None ,
8786):
8887 print_function_args ()
89- e = Events ( )
90- new_event = e . create_build_event ( event_type . BuildQueuedEventV1 , id , name , artifact , data )
88+ build = Build ( build_type = BuildType . BuildQueuedEventV1 , id = id , name = name , artifact = artifact )
89+ build_event = build . create_event ( data )
9190 cdevents_command = CDeventsCommand ()
92- cdevents_command .run (new_event )
91+ cdevents_command .run (build_event )
0 commit comments