Interface to get a driver's trigger event class
In order to properly deserialize trigger events we need a way to get the trigger event class of the drivers. Change-Id: Idb16fd48ced078018e2735153ac213043f03c978
This commit is contained in:
parent
55ac08d3d6
commit
4457ca1086
@ -161,6 +161,11 @@ class TriggerInterface(object, metaclass=abc.ABCMeta):
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def getTriggerEventClass(self):
|
||||
"""Get the drivers's trigger event class."""
|
||||
pass
|
||||
|
||||
|
||||
class SourceInterface(object, metaclass=abc.ABCMeta):
|
||||
"""The source interface to be implemented by a driver.
|
||||
|
@ -15,6 +15,7 @@
|
||||
from zuul.driver import Driver, ConnectionInterface, TriggerInterface
|
||||
from zuul.driver import SourceInterface, ReporterInterface
|
||||
from zuul.driver.gerrit import gerritconnection
|
||||
from zuul.driver.gerrit import gerritmodel
|
||||
from zuul.driver.gerrit import gerrittrigger
|
||||
from zuul.driver.gerrit import gerritsource
|
||||
from zuul.driver.gerrit import gerritreporter
|
||||
@ -49,6 +50,9 @@ class GerritDriver(Driver, ConnectionInterface, TriggerInterface,
|
||||
def getTrigger(self, connection, config=None):
|
||||
return gerrittrigger.GerritTrigger(self, connection, config)
|
||||
|
||||
def getTriggerEventClass(self):
|
||||
return gerritmodel.GerritTriggerEvent
|
||||
|
||||
def getSource(self, connection):
|
||||
return gerritsource.GerritSource(self, connection)
|
||||
|
||||
|
@ -12,9 +12,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from zuul.driver import Driver, ConnectionInterface, SourceInterface
|
||||
from zuul.driver import TriggerInterface
|
||||
from zuul.driver import (
|
||||
Driver, ConnectionInterface, SourceInterface, TriggerInterface
|
||||
)
|
||||
from zuul.driver.git import gitconnection
|
||||
from zuul.driver.git import gitmodel
|
||||
from zuul.driver.git import gitsource
|
||||
from zuul.driver.git import gittrigger
|
||||
|
||||
@ -35,6 +37,9 @@ class GitDriver(Driver, ConnectionInterface, SourceInterface,
|
||||
def getTriggerSchema(self):
|
||||
return gittrigger.getSchema()
|
||||
|
||||
def getTriggerEventClass(self):
|
||||
return gitmodel.GitTriggerEvent
|
||||
|
||||
def getRequireSchema(self):
|
||||
return {}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
from zuul.driver import Driver, ConnectionInterface, TriggerInterface
|
||||
from zuul.driver import SourceInterface, ReporterInterface
|
||||
from zuul.driver.github import githubconnection
|
||||
from zuul.driver.github import githubmodel
|
||||
from zuul.driver.github import githubtrigger
|
||||
from zuul.driver.github import githubsource
|
||||
from zuul.driver.github import githubreporter
|
||||
@ -30,6 +31,9 @@ class GithubDriver(Driver, ConnectionInterface, TriggerInterface,
|
||||
def getTrigger(self, connection, config=None):
|
||||
return githubtrigger.GithubTrigger(self, connection, config)
|
||||
|
||||
def getTriggerEventClass(self):
|
||||
return githubmodel.GithubTriggerEvent
|
||||
|
||||
def getSource(self, connection):
|
||||
return githubsource.GithubSource(self, connection)
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
from zuul.driver import Driver, ConnectionInterface, TriggerInterface
|
||||
from zuul.driver import SourceInterface, ReporterInterface
|
||||
from zuul.driver.gitlab import gitlabconnection
|
||||
from zuul.driver.gitlab import gitlabmodel
|
||||
from zuul.driver.gitlab import gitlabsource
|
||||
from zuul.driver.gitlab import gitlabreporter
|
||||
from zuul.driver.gitlab import gitlabtrigger
|
||||
@ -30,6 +31,9 @@ class GitlabDriver(Driver, ConnectionInterface, TriggerInterface,
|
||||
def getTrigger(self, connection, config=None):
|
||||
return gitlabtrigger.GitlabTrigger(self, connection, config)
|
||||
|
||||
def getTriggerEventClass(self):
|
||||
return gitlabmodel.GitlabTriggerEvent
|
||||
|
||||
def getSource(self, connection):
|
||||
return gitlabsource.GitlabSource(self, connection)
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
from zuul.driver import Driver, ConnectionInterface, TriggerInterface
|
||||
from zuul.driver import SourceInterface, ReporterInterface
|
||||
from zuul.driver.pagure import pagureconnection
|
||||
from zuul.driver.pagure import paguremodel
|
||||
from zuul.driver.pagure import paguresource
|
||||
from zuul.driver.pagure import pagurereporter
|
||||
from zuul.driver.pagure import paguretrigger
|
||||
@ -30,6 +31,9 @@ class PagureDriver(Driver, ConnectionInterface, TriggerInterface,
|
||||
def getTrigger(self, connection, config=None):
|
||||
return paguretrigger.PagureTrigger(self, connection, config)
|
||||
|
||||
def getTriggerEventClass(self):
|
||||
return paguremodel.PagureTriggerEvent
|
||||
|
||||
def getSource(self, connection):
|
||||
return paguresource.PagureSource(self, connection)
|
||||
|
||||
|
@ -23,6 +23,7 @@ from apscheduler.triggers.cron import CronTrigger
|
||||
|
||||
from zuul.driver import Driver, TriggerInterface
|
||||
from zuul.driver.timer import timertrigger
|
||||
from zuul.driver.timer import timermodel
|
||||
from zuul.driver.timer.timermodel import TimerTriggerEvent
|
||||
from zuul.lib.logutil import get_annotated_logger
|
||||
|
||||
@ -141,3 +142,6 @@ class TimerDriver(Driver, TriggerInterface):
|
||||
|
||||
def getTriggerSchema(self):
|
||||
return timertrigger.getSchema()
|
||||
|
||||
def getTriggerEventClass(self):
|
||||
return timermodel.TimerTriggerEvent
|
||||
|
@ -18,6 +18,7 @@ from uuid import uuid4
|
||||
|
||||
from zuul.driver import Driver, TriggerInterface
|
||||
from zuul.driver.zuul.zuulmodel import ZuulTriggerEvent
|
||||
from zuul.driver.zuul import zuulmodel
|
||||
from zuul.driver.zuul import zuultrigger
|
||||
from zuul.lib.logutil import get_annotated_logger
|
||||
|
||||
@ -139,3 +140,6 @@ class ZuulDriver(Driver, TriggerInterface):
|
||||
|
||||
def getTriggerSchema(self):
|
||||
return zuultrigger.getSchema()
|
||||
|
||||
def getTriggerEventClass(self):
|
||||
return zuulmodel.ZuulTriggerEvent
|
||||
|
@ -228,6 +228,10 @@ class ConnectionRegistry(object):
|
||||
connection = self.connections[connection_name]
|
||||
return connection.driver.getTrigger(connection, config)
|
||||
|
||||
def getTriggerEventClass(self, driver_name: str):
|
||||
driver = self.drivers[driver_name]
|
||||
return driver.getTriggerEventClass()
|
||||
|
||||
def getSourceByHostname(self, hostname):
|
||||
for connection in self.connections.values():
|
||||
if hasattr(connection, 'canonical_hostname'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user