22# SPDX-License-Identifier: MIT
33
44from logging import getLogger
5- from typing import Optional
5+ from typing import Optional , Union
66
77from ogr .abstract import GitProject
88
99from packit_service .config import ServiceConfig
1010from packit_service .models import (
1111 AbstractProjectObjectDbType ,
1212 CoprBuildTargetModel ,
13+ KojiBuildTargetModel ,
1314 OSHScanModel ,
1415 ProjectEventModel ,
1516)
@@ -33,14 +34,16 @@ def __init__(
3334 self .commit_sha = commit_sha
3435
3536 self .scan = OSHScanModel .get_by_task_id (task_id )
36- self .build : Optional [CoprBuildTargetModel ] = None
37+ self .build : Optional [Union [ CoprBuildTargetModel , KojiBuildTargetModel ] ] = None
3738 if not self .scan :
3839 logger .warning (
3940 f"Scan with id { task_id } not found in the database."
4041 " It should have been created when receiving the CoprBuildEndEvent"
4142 " and should have been associated with the copr build." ,
4243 )
4344 return
45+
46+ # TODO: How to handle koji builds here?
4447 self .build = self .scan .copr_build_target
4548 if not self .build :
4649 logger .warning (
@@ -54,7 +57,9 @@ def __init__(
5457 # and have to be serialized to be later found in the
5558 # event metadata
5659 self .commit_sha = project_event .commit_sha if not self .commit_sha else self .commit_sha
57- self .identifier = identifier or self .build .identifier
60+ self .identifier = identifier
61+ if not self .identifier and isinstance (self .build , CoprBuildTargetModel ):
62+ self .identifier = self .build .identifier
5863
5964 def get_db_project_object (self ) -> Optional [AbstractProjectObjectDbType ]:
6065 return self .build .get_project_event_object ()
0 commit comments