From 6ad2bccec3952139ef65824ab403abcd5f4baf19 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 04 2021 09:44:21 +0000 Subject: plugin hooks for repo modification Fixes: https://pagure.io/koji/issue/2636 --- diff --git a/builder/kojid b/builder/kojid index 513f8dc..9e1da91 100755 --- a/builder/kojid +++ b/builder/kojid @@ -5458,6 +5458,10 @@ class CreaterepoTask(BaseTaskHandler): 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): @@ -5758,6 +5762,9 @@ class createDistRepoTask(BaseTaskHandler): 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() diff --git a/docs/source/writing_a_plugin.rst b/docs/source/writing_a_plugin.rst index aabc186..400d9e9 100644 --- a/docs/source/writing_a_plugin.rst +++ b/docs/source/writing_a_plugin.rst @@ -216,6 +216,8 @@ builder: - preSCMCheckout - postSCMCheckout +- postCreateDistRepo +- postCreateRepo .. _plugin-cli-command: diff --git a/koji/plugin.py b/koji/plugin.py index a3022e3..4d2e9b6 100644 --- a/koji/plugin.py +++ b/koji/plugin.py @@ -34,6 +34,7 @@ from koji.util import encode_datetime_recurse # the available callback hooks and a list # of functions to be called for each event callbacks = { + # hub 'prePackageListChange': [], 'postPackageListChange': [], 'preTaskStateChange': [], @@ -54,8 +55,11 @@ callbacks = { 'postRepoDone': [], 'preCommit': [], 'postCommit': [], + # builder 'preSCMCheckout': [], 'postSCMCheckout': [], + 'postCreateDistRepo': [], + 'postCreateRepo': [], }