#188 callback fixup
Merged 7 years ago by mikem. Opened 7 years ago by mikeb.
mikeb/koji callback-fixup  into  master

file modified
+5 -8
@@ -4898,7 +4898,7 @@ 

          self.import_metadata()

  

          koji.plugin.run_callbacks('postImport', type='cg', metadata=metadata,

-                     directory=directory, buildinfo=self.buildinfo)

+                                   directory=directory, build=self.buildinfo)

  

          return self.buildinfo

  
@@ -5450,7 +5450,7 @@ 

      WHERE id=%(build_id)i"""

      _dml(update, locals())

      koji.plugin.run_callbacks('postBuildStateChange', attribute='state', old=buildinfo['state'], new=st_complete, info=buildinfo)

-     koji.plugin.run_callbacks('postImport', type='build', in_place=True, srpm=srpm, rpms=rpms)

+     koji.plugin.run_callbacks('postImport', type='build', in_place=True, build=buildinfo, srpm=srpm, rpms=rpms)

      return build_id

  

  def _import_wrapper(task_id, build_info, rpm_results):
@@ -6100,10 +6100,7 @@ 

          #TODO[?] - if sighash is the same, handle more gracefully

          nvra = "%(name)s-%(version)s-%(release)s.%(arch)s" % rinfo

          raise koji.GenericError, "Signature already exists for package %s, key %s" % (nvra, sigkey)

-     callback_info = copy.copy(rinfo)

-     callback_info['sigkey'] = sigkey

-     callback_info['sighash'] = sighash

-     koji.plugin.run_callbacks('preRPMSign', attribute='sighash', old=None, new=sighash, info=callback_info)

+     koji.plugin.run_callbacks('preRPMSign', sigkey=sigkey, sighash=sighash, build=binfo, rpm=rinfo)

      insert = """INSERT INTO rpmsigs(rpm_id, sigkey, sighash)

      VALUES (%(rpm_id)s, %(sigkey)s, %(sighash)s)"""

      _dml(insert, locals())
@@ -6113,7 +6110,7 @@ 

      fo = file(sigpath, 'wb')

      fo.write(sighdr)

      fo.close()

-     koji.plugin.run_callbacks('postRPMSign', attribute='sighash', old=None, new=sighash, info=callback_info)

+     koji.plugin.run_callbacks('postRPMSign', sigkey=sigkey, sighash=sighash, build=binfo, rpm=rinfo)

  

  def _scan_sighdr(sighdr, fn):

      """Splices sighdr with other headers from fn and queries (no payload)"""
@@ -8183,7 +8180,7 @@ 

              _dml(q, {'archive_id': archive['id'], 'rpm_id': rpm_id})

  

      koji.plugin.run_callbacks('postImport', type='image', image=imgdata,

-                               fullpath=fullpath)

+                               build=build_info, fullpath=fullpath)

  

  #

  # XMLRPC Methods

The first commit makes the postImport callback more consistent (build info is always passed in via the build argument).

The second commit changes the arguments passed to the pre/postRPMSign callback. The callback previously passed unnecessary arguments (attribute, old) and put everything else into the "info" argument. This made it ambiguous as to what the fields in info were referring to. The new arguments are more clear, and provide direct access to all information a callback handler is most likely to be interested in.

It would have been possible to make this an additive-only change by pushing the build information into the info dict. However, this would have retained the unnecessary arguments, and made the ambiguity of the name/version/release fields in the info dict worse. This API change cleans things up, and should be minimally disruptive.

Looks fine, but let's give folks a few days to respond on the list

I've seen no objections. Could we go ahead and merge this?

Pull-Request has been merged by mikem

7 years ago
Metadata