Scrub problematic fields from koji fedmsg messages.

This commit is contained in:
Ralph Bean 2014-10-13 20:04:29 +00:00
parent 3a49e0b8bc
commit e7eb813578

View file

@ -143,4 +143,20 @@ def send_message(cbtype, *args, **kws):
# and the secondary hubs off for s390 and ppc.
body['instance'] = 'primary'
# Last thing to do before publishing: scrub some problematic fields
# These fields are floating points which get json-encoded differently on
# rhel and fedora.
problem_fields = ['weight', 'start_ts', 'create_ts', 'completion_ts']
def scrub(obj):
if not isinstance(obj, dict):
return
for key in obj:
if key in problem_fields:
del obj[key]
if isinstance(obj[key], list):
[scrub(item) for item in obj]
if isinstance(obj[key], dict):
[scrub(obj[key]) for key in obj]
scrub(body)
fedmsg.publish(topic=topic, msg=body, modname='buildsys')