#2637 plugin hooks for repo modification
Merged a year ago by tkopecek. Opened a year ago by tkopecek.
tkopecek/koji issue2636  into  master

file modified
+10 -3
@@ -5458,6 +5458,10 @@ 

              with open(os.path.join(self.datadir, "EMPTY_REPO"), 'wt') as fo:

                  fo.write("This repo is empty because its tag has no content for this arch\n")

  

+         tag = self.session.getTag(rinfo['tag_id'], event=rinfo['create_event'], strict=True)['name']

+         self.run_callbacks('postCreateRepo', tag=tag, repodir=self.outdir,

+                            repo_id=self.repo_id, arch=arch)

+ 

          uploadpath = self.getUploadDir()

          files = []

          for f in os.listdir(self.datadir):
@@ -5708,13 +5712,13 @@ 

          oldpkgs = []

          if opts.get('delta'):

              # should be a list of repo ids to delta against

-             for repo_id in opts['delta']:

-                 oldrepo = self.session.repoInfo(repo_id, strict=True)

+             for delta_repo_id in opts['delta']:

+                 oldrepo = self.session.repoInfo(delta_repo_id, strict=True)

                  if not oldrepo['dist']:

                      raise koji.GenericError("Base repo for deltas must also "

                                              "be a dist repo")

                      # regular repos don't actually have rpms, just pkglist

-                 path = koji.pathinfo.distrepo(repo_id, oldrepo['tag_name'])

+                 path = koji.pathinfo.distrepo(delta_repo_id, oldrepo['tag_name'])

                  if not os.path.exists(path):

                      raise koji.GenericError('Base drpm repo missing: %s' % path)

                  # note: since we're using the top level dir, this will handle
@@ -5758,6 +5762,9 @@ 

                  fp.write("This repo is empty because its tag has no content "

                           "for this arch\n")

  

+         self.run_callbacks('postCreateDistRepo', tag=tag, repodir=self.repodir,

+                            repo_id=repo_id, arch=arch, keys=keys, opts=opts)

+ 

          # upload repo files

          self.upload_repo()

          self.upload_repo_manifest()

@@ -216,6 +216,8 @@ 

  

  - preSCMCheckout

  - postSCMCheckout

+ - postCreateDistRepo

+ - postCreateRepo

  

  .. _plugin-cli-command:

  

file modified
+4
@@ -34,6 +34,7 @@ 

  # the available callback hooks and a list

  # of functions to be called for each event

  callbacks = {

+     # hub

      'prePackageListChange': [],

      'postPackageListChange': [],

      'preTaskStateChange': [],
@@ -54,8 +55,11 @@ 

      'postRepoDone': [],

      'preCommit': [],

      'postCommit': [],

+     # builder

      'preSCMCheckout': [],

      'postSCMCheckout': [],

+     'postCreateDistRepo': [],

+     'postCreateRepo': [],

  }

  

  

Awesome! (I have not tested it)

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

a year ago

Metadata Update from @jcupova:
- Pull-request untagged with: testing-ready

a year ago
[mikem@localhost koji]$ flake8 builder/kojid
builder/kojid:5458:50: F821 undefined name 'tag'

In the postCreateDistRepo callback the repo_id value passed in might have been reset by the earlier bit of code:

        if opts.get('delta'):
            # should be a list of repo ids to delta against
            for repo_id in opts['delta']:

We should adjust that loop so that it uses its own variable.

Otherwise looks fine. Simple enough to add hooks. Hopefully this is sufficient for the plugins folks want to write.

rebased onto 88c3ffc2c2a78cecf457cff5158daee2ab2d902f

a year ago

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

a year ago

1 new commit added

  • rename local variable
a year ago

Thanks for the updates!

tag = self.session.getTag(rinfo['tag_id'], strict=True)['name']
self.run_callbacks('postCreateRepo', tag=tag, repodir=self.outdir,
                   repo_id=self.repo_id, arch=arch)

For consistency, we should probably query the tag at the event for the repo.

rebased onto 6ad2bcc

a year ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

a year ago

Commit 006f4de fixes this pull-request

Pull-Request has been merged by tkopecek

a year ago