11""" 
22Default action is listed below. 
33`init` is required; and requires at minimum the `jira_project_key` parameter. 
4+ The `label_field` parameter configures which Jira field is used to store the 
5+ labels generated from the Bugzilla status whiteboard. 
46
57`init` should return a __call__able 
68""" 
79import  logging 
10+ from  typing  import  Any 
811
912from  jbi  import  ActionResult , Operation 
1013from  jbi .environment  import  get_settings 
2528}
2629
2730
28- def  init (jira_project_key , ** kwargs ):
31+ def  init (jira_project_key , sync_whiteboard_labels = True ,  ** kwargs ):
2932    """Function that takes required and optional params and returns a callable object""" 
30-     return  DefaultExecutor (jira_project_key = jira_project_key , ** kwargs )
33+     return  DefaultExecutor (
34+         jira_project_key = jira_project_key ,
35+         sync_whiteboard_labels = sync_whiteboard_labels ,
36+         ** kwargs ,
37+     )
3138
3239
3340class  DefaultExecutor :
@@ -36,6 +43,7 @@ class DefaultExecutor:
3643    def  __init__ (self , jira_project_key , ** kwargs ):
3744        """Initialize DefaultExecutor Object""" 
3845        self .jira_project_key  =  jira_project_key 
46+         self .sync_whiteboard_labels  =  kwargs .get ("sync_whiteboard_labels" , True )
3947
4048        self .bugzilla_client  =  get_bugzilla ()
4149        self .jira_client  =  get_jira ()
@@ -100,6 +108,17 @@ def comment_create_or_noop(self, payload: BugzillaWebhookRequest) -> ActionResul
100108        )
101109        return  True , {"jira_response" : jira_response }
102110
111+     def  jira_fields (self , bug_obj : BugzillaBug ):
112+         """Extract bug info as jira issue dictionary""" 
113+         fields : dict [str , Any ] =  {
114+             "summary" : bug_obj .summary ,
115+         }
116+ 
117+         if  self .sync_whiteboard_labels :
118+             fields ["labels" ] =  bug_obj .get_jira_labels ()
119+ 
120+         return  fields 
121+ 
103122    def  jira_comments_for_update (
104123        self ,
105124        payload : BugzillaWebhookRequest ,
@@ -143,7 +162,7 @@ def bug_create_or_update(
143162            },
144163        )
145164        jira_response_update  =  self .jira_client .update_issue_field (
146-             key = linked_issue_key , fields = bug_obj . map_as_jira_issue ( )
165+             key = linked_issue_key , fields = self . jira_fields ( bug_obj )
147166        )
148167
149168        comments  =  self .jira_comments_for_update (payload )
@@ -193,7 +212,7 @@ def create_and_link_issue(  # pylint: disable=too-many-locals
193212        ]
194213
195214        fields  =  {
196-             ** bug_obj . map_as_jira_issue ( ),  # type: ignore 
215+             ** self . jira_fields ( bug_obj ),  # type: ignore 
197216            "issuetype" : {"name" : bug_obj .issue_type ()},
198217            "description" : description ,
199218            "project" : {"key" : self .jira_project_key },
0 commit comments