kojid: extend SCM.assert_allowed with hub policy
This is a simple extention of `SCM.assert_allowed` - `assert_allowed_by_policy` will set the default "use_common" to False which is different to the old behavior - `channel`, `user_id`, `scratch` are passed in the `policy_data` with scminfo right now. This is a prototype for this change, and there are some other solutions could be implemented too - Use a scmpolicy plugin as `postSCMCheckout` callback, the pro is that we can do more checks after the source is initialized on builder, meanwhile, the con is that the source will be downloaded even it is denied by policy. It might be a potential risk? - Do the scm check in hub's `make_task`, this looks straightforward, but may lack some builder's information fixes: #2757
This commit is contained in:
parent
ec70d21c41
commit
47c4b5d70b
8 changed files with 431 additions and 25 deletions
|
|
@ -312,6 +312,7 @@ class BaseTaskHandler(object):
|
|||
self.workdir = workdir
|
||||
self.logger = logging.getLogger("koji.build.BaseTaskHandler")
|
||||
self.manager = None
|
||||
self.taskinfo = None
|
||||
|
||||
def setManager(self, manager):
|
||||
"""Set the manager attribute
|
||||
|
|
@ -597,15 +598,20 @@ class BaseTaskHandler(object):
|
|||
|
||||
def run_callbacks(self, plugin, *args, **kwargs):
|
||||
if 'taskinfo' not in kwargs:
|
||||
try:
|
||||
taskinfo = self.taskinfo
|
||||
except AttributeError:
|
||||
self.taskinfo = self.session.getTaskInfo(self.id, request=True)
|
||||
taskinfo = self.taskinfo
|
||||
kwargs['taskinfo'] = taskinfo
|
||||
kwargs['taskinfo'] = self.taskinfo
|
||||
kwargs['session'] = self.session
|
||||
koji.plugin.run_callbacks(plugin, *args, **kwargs)
|
||||
|
||||
@property
|
||||
def taskinfo(self):
|
||||
if not getattr(self, '_taskinfo', None):
|
||||
self._taskinfo = self.session.getTaskInfo(self.id, request=True, strict=True)
|
||||
return self._taskinfo
|
||||
|
||||
@taskinfo.setter
|
||||
def taskinfo(self, taskinfo):
|
||||
self._taskinfo = taskinfo
|
||||
|
||||
|
||||
class FakeTask(BaseTaskHandler):
|
||||
Methods = ['someMethod']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue