@@ -446,6 +446,26 @@ def is_final(v):
446
446
for payload_el , params_el in zip (payload , params ):
447
447
cls ._merge_payload_with_extra_params (payload_el , params_el )
448
448
449
+ def _inject_extra_params (self , payload : dict ) -> dict :
450
+ if not hasattr (self .job_config , "tf_extra_params" ):
451
+ return payload
452
+
453
+ extra_params = self .job_config .tf_extra_params
454
+ # Merge only some subtrees, we do not want the user to override notification or api_key!
455
+ for subtree in TESTING_FARM_EXTRA_PARAM_MERGED_SUBTREES :
456
+ if subtree not in extra_params :
457
+ continue
458
+
459
+ if subtree not in payload :
460
+ payload [subtree ] = extra_params [subtree ]
461
+ else :
462
+ self ._merge_payload_with_extra_params (
463
+ payload [subtree ],
464
+ extra_params [subtree ],
465
+ )
466
+
467
+ return payload
468
+
449
469
@classmethod
450
470
def _handle_extra_artifacts (cls , payload : Any , extra_params_artifacts : Any ):
451
471
"""
@@ -599,23 +619,7 @@ def _payload(
599
619
},
600
620
}
601
621
602
- if hasattr (self .job_config , "tf_extra_params" ):
603
- extra_params = self .job_config .tf_extra_params
604
- else :
605
- extra_params = {}
606
- # Merge only some subtrees, we do not want the user to override notification or api_key!
607
- for subtree in TESTING_FARM_EXTRA_PARAM_MERGED_SUBTREES :
608
- if subtree not in extra_params :
609
- continue
610
- if subtree not in payload :
611
- payload [subtree ] = extra_params [subtree ]
612
- else :
613
- self ._merge_payload_with_extra_params (
614
- payload [subtree ],
615
- extra_params [subtree ],
616
- )
617
-
618
- return payload
622
+ return self ._inject_extra_params (payload )
619
623
620
624
def _payload_install_test (self , build_id : int , target : str , compose : str ) -> dict :
621
625
"""
@@ -625,31 +629,41 @@ def _payload_install_test(self, build_id: int, target: str, compose: str) -> dic
625
629
"""
626
630
copr_build = CoprBuildTargetModel .get_by_build_id (build_id )
627
631
distro , arch = target .rsplit ("-" , 1 )
628
- return {
629
- "api_key" : self .service_config .testing_farm_secret ,
630
- "test" : {
631
- "tmt" : {
632
- "url" : TESTING_FARM_INSTALLABILITY_TEST_URL ,
633
- "ref" : TESTING_FARM_INSTALLABILITY_TEST_REF ,
634
- "name" : "/packit/installation" ,
635
- },
636
- },
637
- "environments" : [
638
- {
639
- "arch" : arch ,
640
- "os" : {"compose" : compose },
641
- "variables" : {
642
- "REPOSITORY" : f"{ copr_build .owner } /{ copr_build .project_name } " ,
632
+ return self ._inject_extra_params (
633
+ {
634
+ "api_key" : self .service_config .testing_farm_secret ,
635
+ "test" : {
636
+ "tmt" : {
637
+ "url" : TESTING_FARM_INSTALLABILITY_TEST_URL ,
638
+ "ref" : TESTING_FARM_INSTALLABILITY_TEST_REF ,
639
+ "name" : "/packit/installation" ,
643
640
},
644
641
},
645
- ],
646
- "notification" : {
647
- "webhook" : {
648
- "url" : f"{ self .api_url } /testing-farm/results" ,
649
- "token" : self .service_config .testing_farm_secret ,
642
+ "environments" : [
643
+ {
644
+ "arch" : arch ,
645
+ "os" : {"compose" : compose },
646
+ "variables" : {
647
+ "REPOSITORY" : f"{ copr_build .owner } /{ copr_build .project_name } " ,
648
+ },
649
+ "tmt" : {
650
+ "context" : {
651
+ "distro" : distro ,
652
+ "arch" : arch ,
653
+ "trigger" : "commit" ,
654
+ "initiator" : "packit" ,
655
+ },
656
+ },
657
+ },
658
+ ],
659
+ "notification" : {
660
+ "webhook" : {
661
+ "url" : f"{ self .api_url } /testing-farm/results" ,
662
+ "token" : self .service_config .testing_farm_secret ,
663
+ },
650
664
},
651
- },
652
- }
665
+ }
666
+ )
653
667
654
668
def check_comment_pr_argument_and_report (self ) -> bool :
655
669
"""
0 commit comments