Merge "Require tenant in Pipeline constructor"
This commit is contained in:
commit
db9bc5b87f
|
@ -53,7 +53,7 @@ class TestJob(BaseTestCase):
|
|||
'test', False)
|
||||
self.tpc = model.TenantProjectConfig(self.project)
|
||||
self.tenant.addUntrustedProject(self.tpc)
|
||||
self.pipeline = model.Pipeline('gate', self.layout)
|
||||
self.pipeline = model.Pipeline('gate', self.tenant)
|
||||
self.pipeline.source_context = self.context
|
||||
self.layout.addPipeline(self.pipeline)
|
||||
self.queue = model.ChangeQueue(self.pipeline)
|
||||
|
@ -153,7 +153,7 @@ class TestJob(BaseTestCase):
|
|||
job.applyVariant(bad_final, self.layout)
|
||||
|
||||
def test_job_inheritance_job_tree(self):
|
||||
pipeline = model.Pipeline('gate', self.layout)
|
||||
pipeline = model.Pipeline('gate', self.tenant)
|
||||
pipeline.source_context = self.context
|
||||
self.layout.addPipeline(pipeline)
|
||||
queue = model.ChangeQueue(pipeline)
|
||||
|
@ -228,7 +228,7 @@ class TestJob(BaseTestCase):
|
|||
self.assertEqual(job.timeout, 70)
|
||||
|
||||
def test_inheritance_keeps_matchers(self):
|
||||
pipeline = model.Pipeline('gate', self.layout)
|
||||
pipeline = model.Pipeline('gate', self.tenant)
|
||||
pipeline.source_context = self.context
|
||||
self.layout.addPipeline(pipeline)
|
||||
queue = model.ChangeQueue(pipeline)
|
||||
|
|
|
@ -1040,7 +1040,7 @@ class PipelineParser(object):
|
|||
|
||||
def fromYaml(self, conf):
|
||||
self.schema(conf)
|
||||
pipeline = model.Pipeline(conf['name'], self.pcontext.tenant.name)
|
||||
pipeline = model.Pipeline(conf['name'], self.pcontext.tenant)
|
||||
pipeline.source_context = conf['_source_context']
|
||||
pipeline.description = conf.get('description')
|
||||
|
||||
|
@ -1722,8 +1722,6 @@ class TenantParser(object):
|
|||
# reference_exceptions has it; add tests if needed.
|
||||
if not skip_pipelines:
|
||||
for pipeline in parsed_config.pipelines:
|
||||
if not pipeline.tenant:
|
||||
pipeline.tenant = tenant
|
||||
layout.addPipeline(pipeline)
|
||||
|
||||
for nodeset in parsed_config.nodesets:
|
||||
|
|
|
@ -39,7 +39,7 @@ class GithubReporter(BaseReporter):
|
|||
self._unlabels = self.config.get('unlabel', [])
|
||||
if not isinstance(self._unlabels, list):
|
||||
self._unlabels = [self._unlabels]
|
||||
self.context = "{}/{}".format(pipeline.tenant_name, pipeline.name)
|
||||
self.context = "{}/{}".format(pipeline.tenant.name, pipeline.name)
|
||||
|
||||
def report(self, item):
|
||||
"""Report on an event."""
|
||||
|
|
|
@ -47,7 +47,7 @@ class PipelineManager(object):
|
|||
|
||||
def __init__(self, sched, pipeline):
|
||||
self.log = logging.getLogger("zuul.Pipeline.%s.%s" %
|
||||
(pipeline.tenant_name,
|
||||
(pipeline.tenant.name,
|
||||
pipeline.name,))
|
||||
self.sched = sched
|
||||
self.pipeline = pipeline
|
||||
|
|
|
@ -180,11 +180,14 @@ class Pipeline(object):
|
|||
Reporter
|
||||
Communicates success and failure results somewhere
|
||||
"""
|
||||
def __init__(self, name, tenant_name):
|
||||
def __init__(self, name, tenant):
|
||||
self.name = name
|
||||
self.tenant_name = tenant_name
|
||||
# Note that pipelines are not portable across tenants (new
|
||||
# pipeline objects must be made when a tenant is
|
||||
# reconfigured). A pipeline requires a tenant in order to
|
||||
# reach the currently active layout for that tenant.
|
||||
self.tenant = tenant
|
||||
self.source_context = None
|
||||
self.tenant = None
|
||||
self.description = None
|
||||
self.failure_message = None
|
||||
self.merge_failure_message = None
|
||||
|
@ -2989,6 +2992,11 @@ class Layout(object):
|
|||
self.semaphores[semaphore.name] = semaphore
|
||||
|
||||
def addPipeline(self, pipeline):
|
||||
if pipeline.tenant is not self.tenant:
|
||||
raise Exception("Pipeline created for tenant %s "
|
||||
"may not be added to %s" % (
|
||||
pipeline.tenant,
|
||||
self.tenant))
|
||||
self.pipelines[pipeline.name] = pipeline
|
||||
|
||||
def addProjectTemplate(self, project_template):
|
||||
|
|
Loading…
Reference in New Issue