mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 11:48:33 +08:00
Rather extend koji message so we can have additional arguments for copr
This commit is contained in:
@@ -216,11 +216,12 @@ class BaseMessage(object):
|
||||
msg_id, msg_inner_msg.get('id'), msg_inner_msg.get('state'))
|
||||
|
||||
elif conf.system == category == 'copr' and object == 'build':
|
||||
copr = msg_inner_msg.get('copr')
|
||||
build = msg_inner_msg.get('build')
|
||||
status = msg_inner_msg.get('status')
|
||||
pkg = msg_inner_msg.get('pkg')
|
||||
what = msg_inner_msg.get('what')
|
||||
msg_obj = CoprBuildEnd(msg_id, build, status, pkg, what)
|
||||
msg_obj = CoprBuildEnd(msg_id, build, status, copr, pkg, what)
|
||||
|
||||
# If the message matched the regex and is important to the app,
|
||||
# it will be returned
|
||||
@@ -271,7 +272,7 @@ class KojiRepoChange(BaseMessage):
|
||||
self.repo_tag = repo_tag
|
||||
|
||||
|
||||
class CoprBuildEnd(object):
|
||||
class CoprBuildEnd(KojiBuildChange):
|
||||
""" A wrapper class that transforms copr message attributes
|
||||
to a KojiBuildChange message object
|
||||
:param msg_id: the id of the msg (e.g. 2016-SomeGUID)
|
||||
@@ -282,9 +283,9 @@ class CoprBuildEnd(object):
|
||||
(e.g. mutt-kz-1.5.23.1-1.20150203.git.c8504a8a.fc21)
|
||||
:param state_reason: the optional reason as to why the state changed
|
||||
"""
|
||||
def __new__(cls, msg_id, build_id, status, pkg, what=None):
|
||||
def __init__(self, msg_id, build_id, status, copr, pkg, what=None):
|
||||
nvr = kobo.rpmlib.parse_nvra(pkg)
|
||||
return KojiBuildChange(
|
||||
super(CoprBuildEnd, self).__init__(
|
||||
msg_id=msg_id,
|
||||
build_id=build_id,
|
||||
task_id=build_id,
|
||||
@@ -294,6 +295,7 @@ class CoprBuildEnd(object):
|
||||
build_release=".".join(s for s in [nvr["release"], nvr["epoch"], nvr["arch"]] if s),
|
||||
state_reason=what,
|
||||
)
|
||||
self.copr = copr
|
||||
|
||||
|
||||
class MBSModule(BaseMessage):
|
||||
|
||||
@@ -375,7 +375,7 @@ class ComponentBuild(MBSBase):
|
||||
|
||||
@classmethod
|
||||
def from_component_event(cls, session, event):
|
||||
if type(event) == module_build_service.messaging.KojiBuildChange:
|
||||
if isinstance(event, module_build_service.messaging.KojiBuildChange):
|
||||
if event.module_build_id:
|
||||
return session.query(cls).filter_by(
|
||||
task_id=event.task_id, module_id=event.module_build_id)\
|
||||
|
||||
@@ -178,7 +178,7 @@ class MBSConsumer(fedmsg.consumers.FedmsgConsumer):
|
||||
build = None
|
||||
|
||||
# Choose a handler for this message
|
||||
if type(msg) == module_build_service.messaging.KojiBuildChange:
|
||||
if isinstance(msg, module_build_service.messaging.KojiBuildChange):
|
||||
handler = self.on_build_change[msg.build_new_state]
|
||||
build = models.ComponentBuild.from_component_event(session, msg)
|
||||
if build:
|
||||
|
||||
Reference in New Issue
Block a user