Replace config/project repos with config/untrusted projects
The config-repo / project-repo terminology is confusing and we've generally been using trusted-project and untrusted-project instead. The term "untrusted-project" is straightforward, but "trusted-project" is a little misleading, since there are other characteristics which define it (notably, that the configuration held in it is branchless). A better term for that might be "config-project". Since the main config now directly refers to projects rather than repos, complete the transition by replacing all config-repo occurances with config-project and likewise project-repo with untrusted-project. Change-Id: I2341aa94e3622e2647b0506b78bc84dbcdec1901 Story: 2000953
This commit is contained in:
parent
0ffa010656
commit
109da3f9a7
|
@ -1475,9 +1475,9 @@ class ZuulTestCase(BaseTestCase):
|
||||||
for tenant in tenant_config:
|
for tenant in tenant_config:
|
||||||
sources = tenant['tenant']['source']
|
sources = tenant['tenant']['source']
|
||||||
for source, conf in sources.items():
|
for source, conf in sources.items():
|
||||||
for project in conf.get('config-repos', []):
|
for project in conf.get('config-projects', []):
|
||||||
self.setupProjectKeys(source, project)
|
self.setupProjectKeys(source, project)
|
||||||
for project in conf.get('project-repos', []):
|
for project in conf.get('untrusted-projects', []):
|
||||||
self.setupProjectKeys(source, project)
|
self.setupProjectKeys(source, project)
|
||||||
|
|
||||||
def setupProjectKeys(self, source, project):
|
def setupProjectKeys(self, source, project):
|
||||||
|
@ -1927,9 +1927,9 @@ class ZuulTestCase(BaseTestCase):
|
||||||
def getPipeline(self, name):
|
def getPipeline(self, name):
|
||||||
return self.sched.abide.tenants.values()[0].layout.pipelines.get(name)
|
return self.sched.abide.tenants.values()[0].layout.pipelines.get(name)
|
||||||
|
|
||||||
def updateConfigLayout(self, path, project_repos=None):
|
def updateConfigLayout(self, path, untrusted_projects=None):
|
||||||
if project_repos is None:
|
if untrusted_projects is None:
|
||||||
project_repos = []
|
untrusted_projects = []
|
||||||
root = os.path.join(self.test_root, "config")
|
root = os.path.join(self.test_root, "config")
|
||||||
if not os.path.exists(root):
|
if not os.path.exists(root):
|
||||||
os.makedirs(root)
|
os.makedirs(root)
|
||||||
|
@ -1939,9 +1939,9 @@ class ZuulTestCase(BaseTestCase):
|
||||||
name: openstack
|
name: openstack
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- %s
|
- %s
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project
|
- org/project
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
@ -1959,7 +1959,7 @@ class ZuulTestCase(BaseTestCase):
|
||||||
- org/experimental-project
|
- org/experimental-project
|
||||||
- org/no-jobs-project\n""" % path)
|
- org/no-jobs-project\n""" % path)
|
||||||
|
|
||||||
for repo in project_repos:
|
for repo in untrusted_projects:
|
||||||
f.write(" - %s\n" % repo)
|
f.write(" - %s\n" % repo)
|
||||||
f.close()
|
f.close()
|
||||||
self.config.set('zuul', 'tenant_config',
|
self.config.set('zuul', 'tenant_config',
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project
|
- org/project
|
||||||
- bare-role
|
- bare-role
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project
|
- org/project
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name: tenant-duplicate
|
name: tenant-duplicate
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project
|
- org/project
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
git:
|
git:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
gerrit:
|
gerrit:
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project
|
- org/project
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project
|
- org/project
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project-cherry-pick
|
- org/project-cherry-pick
|
||||||
- org/project-merge
|
- org/project-merge
|
||||||
- org/project-merge-branches
|
- org/project-merge-branches
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
- tenant-one-config
|
- tenant-one-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@
|
||||||
name: tenant-two
|
name: tenant-two
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
- tenant-two-config
|
- tenant-two-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,18 +2,18 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
- tenant-one-config
|
- tenant-one-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
|
|
||||||
- tenant:
|
- tenant:
|
||||||
name: tenant-two
|
name: tenant-two
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
- tenant-two-config
|
- tenant-two-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/one-job-project
|
- org/one-job-project
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: openstack
|
name: openstack
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- project-config
|
- project-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- openstack/nova
|
- openstack/nova
|
||||||
- openstack/keystone
|
- openstack/keystone
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- current-project
|
- current-project
|
||||||
- open-project
|
- open-project
|
||||||
- status-project
|
- status-project
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project
|
- org/project
|
||||||
- org/project1
|
- org/project1
|
||||||
- org/project2
|
- org/project2
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project
|
- org/project
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/docs
|
- org/docs
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/templated-project
|
- org/templated-project
|
||||||
- org/layered-project
|
- org/layered-project
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
review_gerrit:
|
review_gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
another_gerrit:
|
another_gerrit:
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project1
|
- org/project1
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
review_gerrit:
|
review_gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project
|
- org/project
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
project-repos:
|
untrusted-projects:
|
||||||
- org/project
|
- org/project
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
name: tenant-one
|
name: tenant-one
|
||||||
source:
|
source:
|
||||||
gerrit:
|
gerrit:
|
||||||
config-repos:
|
config-projects:
|
||||||
- common-config
|
- common-config
|
||||||
|
|
|
@ -27,10 +27,10 @@ class TestGitDriver(ZuulTestCase):
|
||||||
tenant = self.sched.abide.tenants.get('tenant-one')
|
tenant = self.sched.abide.tenants.get('tenant-one')
|
||||||
# Check that we have the git source for common-config and the
|
# Check that we have the git source for common-config and the
|
||||||
# gerrit source for the project.
|
# gerrit source for the project.
|
||||||
self.assertEqual('git', tenant.config_repos[0].source.name)
|
self.assertEqual('git', tenant.config_projects[0].source.name)
|
||||||
self.assertEqual('common-config', tenant.config_repos[0].name)
|
self.assertEqual('common-config', tenant.config_projects[0].name)
|
||||||
self.assertEqual('gerrit', tenant.project_repos[0].source.name)
|
self.assertEqual('gerrit', tenant.untrusted_projects[0].source.name)
|
||||||
self.assertEqual('org/project', tenant.project_repos[0].name)
|
self.assertEqual('org/project', tenant.untrusted_projects[0].name)
|
||||||
|
|
||||||
# The configuration for this test is accessed via the git
|
# The configuration for this test is accessed via the git
|
||||||
# driver (in common-config), rather than the gerrit driver, so
|
# driver (in common-config), rather than the gerrit driver, so
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TestJob(BaseTestCase):
|
||||||
self.tenant = model.Tenant('tenant')
|
self.tenant = model.Tenant('tenant')
|
||||||
self.layout = model.Layout()
|
self.layout = model.Layout()
|
||||||
self.project = model.Project('project', self.source)
|
self.project = model.Project('project', self.source)
|
||||||
self.tenant.addProjectRepo(self.project)
|
self.tenant.addUntrustedProject(self.project)
|
||||||
self.pipeline = model.Pipeline('gate', self.layout)
|
self.pipeline = model.Pipeline('gate', self.layout)
|
||||||
self.layout.addPipeline(self.pipeline)
|
self.layout.addPipeline(self.pipeline)
|
||||||
self.queue = model.ChangeQueue(self.pipeline)
|
self.queue = model.ChangeQueue(self.pipeline)
|
||||||
|
@ -165,7 +165,7 @@ class TestJob(BaseTestCase):
|
||||||
layout.addPipeline(pipeline)
|
layout.addPipeline(pipeline)
|
||||||
queue = model.ChangeQueue(pipeline)
|
queue = model.ChangeQueue(pipeline)
|
||||||
project = model.Project('project', self.source)
|
project = model.Project('project', self.source)
|
||||||
tenant.addProjectRepo(project)
|
tenant.addUntrustedProject(project)
|
||||||
|
|
||||||
base = configloader.JobParser.fromYaml(tenant, layout, {
|
base = configloader.JobParser.fromYaml(tenant, layout, {
|
||||||
'_source_context': self.context,
|
'_source_context': self.context,
|
||||||
|
@ -432,7 +432,7 @@ class TestJob(BaseTestCase):
|
||||||
def test_job_inheritance_job_tree(self):
|
def test_job_inheritance_job_tree(self):
|
||||||
tenant = model.Tenant('tenant')
|
tenant = model.Tenant('tenant')
|
||||||
layout = model.Layout()
|
layout = model.Layout()
|
||||||
tenant.addProjectRepo(self.project)
|
tenant.addUntrustedProject(self.project)
|
||||||
|
|
||||||
pipeline = model.Pipeline('gate', layout)
|
pipeline = model.Pipeline('gate', layout)
|
||||||
layout.addPipeline(pipeline)
|
layout.addPipeline(pipeline)
|
||||||
|
@ -513,7 +513,7 @@ class TestJob(BaseTestCase):
|
||||||
layout.addPipeline(pipeline)
|
layout.addPipeline(pipeline)
|
||||||
queue = model.ChangeQueue(pipeline)
|
queue = model.ChangeQueue(pipeline)
|
||||||
project = model.Project('project', self.source)
|
project = model.Project('project', self.source)
|
||||||
tenant.addProjectRepo(project)
|
tenant.addUntrustedProject(project)
|
||||||
|
|
||||||
base = configloader.JobParser.fromYaml(tenant, layout, {
|
base = configloader.JobParser.fromYaml(tenant, layout, {
|
||||||
'_source_context': self.context,
|
'_source_context': self.context,
|
||||||
|
@ -594,7 +594,7 @@ class TestJob(BaseTestCase):
|
||||||
self.layout.addJob(job)
|
self.layout.addJob(job)
|
||||||
|
|
||||||
project2 = model.Project('project2', self.source)
|
project2 = model.Project('project2', self.source)
|
||||||
self.tenant.addProjectRepo(project2)
|
self.tenant.addUntrustedProject(project2)
|
||||||
context2 = model.SourceContext(project2, 'master',
|
context2 = model.SourceContext(project2, 'master',
|
||||||
'test', True)
|
'test', True)
|
||||||
|
|
||||||
|
@ -795,7 +795,7 @@ class TestTenant(BaseTestCase):
|
||||||
connection=connection1)
|
connection=connection1)
|
||||||
|
|
||||||
source1_project1 = model.Project('project1', source1)
|
source1_project1 = model.Project('project1', source1)
|
||||||
tenant.addConfigRepo(source1_project1)
|
tenant.addConfigProject(source1_project1)
|
||||||
d = {'project1':
|
d = {'project1':
|
||||||
{'git1.example.com': source1_project1}}
|
{'git1.example.com': source1_project1}}
|
||||||
self.assertEqual(d, tenant.projects)
|
self.assertEqual(d, tenant.projects)
|
||||||
|
@ -805,7 +805,7 @@ class TestTenant(BaseTestCase):
|
||||||
tenant.getProject('git1.example.com/project1'))
|
tenant.getProject('git1.example.com/project1'))
|
||||||
|
|
||||||
source1_project2 = model.Project('project2', source1)
|
source1_project2 = model.Project('project2', source1)
|
||||||
tenant.addProjectRepo(source1_project2)
|
tenant.addUntrustedProject(source1_project2)
|
||||||
d = {'project1':
|
d = {'project1':
|
||||||
{'git1.example.com': source1_project1},
|
{'git1.example.com': source1_project1},
|
||||||
'project2':
|
'project2':
|
||||||
|
@ -822,7 +822,7 @@ class TestTenant(BaseTestCase):
|
||||||
connection=connection2)
|
connection=connection2)
|
||||||
|
|
||||||
source2_project1 = model.Project('project1', source2)
|
source2_project1 = model.Project('project1', source2)
|
||||||
tenant.addProjectRepo(source2_project1)
|
tenant.addUntrustedProject(source2_project1)
|
||||||
d = {'project1':
|
d = {'project1':
|
||||||
{'git1.example.com': source1_project1,
|
{'git1.example.com': source1_project1,
|
||||||
'git2.example.com': source2_project1},
|
'git2.example.com': source2_project1},
|
||||||
|
@ -841,7 +841,7 @@ class TestTenant(BaseTestCase):
|
||||||
tenant.getProject('git2.example.com/project1'))
|
tenant.getProject('git2.example.com/project1'))
|
||||||
|
|
||||||
source2_project2 = model.Project('project2', source2)
|
source2_project2 = model.Project('project2', source2)
|
||||||
tenant.addConfigRepo(source2_project2)
|
tenant.addConfigProject(source2_project2)
|
||||||
d = {'project1':
|
d = {'project1':
|
||||||
{'git1.example.com': source1_project1,
|
{'git1.example.com': source1_project1,
|
||||||
'git2.example.com': source2_project1},
|
'git2.example.com': source2_project1},
|
||||||
|
@ -867,7 +867,7 @@ class TestTenant(BaseTestCase):
|
||||||
tenant.getProject('git2.example.com/project2'))
|
tenant.getProject('git2.example.com/project2'))
|
||||||
|
|
||||||
source1_project2b = model.Project('subpath/project2', source1)
|
source1_project2b = model.Project('subpath/project2', source1)
|
||||||
tenant.addConfigRepo(source1_project2b)
|
tenant.addConfigProject(source1_project2b)
|
||||||
d = {'project1':
|
d = {'project1':
|
||||||
{'git1.example.com': source1_project1,
|
{'git1.example.com': source1_project1,
|
||||||
'git2.example.com': source2_project1},
|
'git2.example.com': source2_project1},
|
||||||
|
@ -888,7 +888,7 @@ class TestTenant(BaseTestCase):
|
||||||
tenant.getProject('git1.example.com/subpath/project2'))
|
tenant.getProject('git1.example.com/subpath/project2'))
|
||||||
|
|
||||||
source2_project2b = model.Project('subpath/project2', source2)
|
source2_project2b = model.Project('subpath/project2', source2)
|
||||||
tenant.addConfigRepo(source2_project2b)
|
tenant.addConfigProject(source2_project2b)
|
||||||
d = {'project1':
|
d = {'project1':
|
||||||
{'git1.example.com': source1_project1,
|
{'git1.example.com': source1_project1,
|
||||||
'git2.example.com': source2_project1},
|
'git2.example.com': source2_project1},
|
||||||
|
|
|
@ -754,8 +754,8 @@ class SemaphoreParser(object):
|
||||||
class TenantParser(object):
|
class TenantParser(object):
|
||||||
log = logging.getLogger("zuul.TenantParser")
|
log = logging.getLogger("zuul.TenantParser")
|
||||||
|
|
||||||
tenant_source = vs.Schema({'config-repos': [str],
|
tenant_source = vs.Schema({'config-projects': [str],
|
||||||
'project-repos': [str]})
|
'untrusted-projects': [str]})
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def validateTenantSources(connections):
|
def validateTenantSources(connections):
|
||||||
|
@ -785,20 +785,20 @@ class TenantParser(object):
|
||||||
tenant = model.Tenant(conf['name'])
|
tenant = model.Tenant(conf['name'])
|
||||||
tenant.unparsed_config = conf
|
tenant.unparsed_config = conf
|
||||||
unparsed_config = model.UnparsedTenantConfig()
|
unparsed_config = model.UnparsedTenantConfig()
|
||||||
config_repos, project_repos = \
|
config_projects, untrusted_projects = \
|
||||||
TenantParser._loadTenantConfigRepos(
|
TenantParser._loadTenantProjects(
|
||||||
project_key_dir, connections, conf)
|
project_key_dir, connections, conf)
|
||||||
for repo in config_repos:
|
for project in config_projects:
|
||||||
tenant.addConfigRepo(repo)
|
tenant.addConfigProject(project)
|
||||||
for repo in project_repos:
|
for project in untrusted_projects:
|
||||||
tenant.addProjectRepo(repo)
|
tenant.addUntrustedProject(project)
|
||||||
tenant.config_repos_config, tenant.project_repos_config = \
|
tenant.config_projects_config, tenant.untrusted_projects_config = \
|
||||||
TenantParser._loadTenantInRepoLayouts(merger, connections,
|
TenantParser._loadTenantInRepoLayouts(merger, connections,
|
||||||
tenant.config_repos,
|
tenant.config_projects,
|
||||||
tenant.project_repos,
|
tenant.untrusted_projects,
|
||||||
cached)
|
cached)
|
||||||
unparsed_config.extend(tenant.config_repos_config)
|
unparsed_config.extend(tenant.config_projects_config)
|
||||||
unparsed_config.extend(tenant.project_repos_config)
|
unparsed_config.extend(tenant.untrusted_projects_config)
|
||||||
tenant.layout = TenantParser._parseLayout(base, tenant,
|
tenant.layout = TenantParser._parseLayout(base, tenant,
|
||||||
unparsed_config,
|
unparsed_config,
|
||||||
scheduler,
|
scheduler,
|
||||||
|
@ -852,41 +852,41 @@ class TenantParser(object):
|
||||||
encryption.deserialize_rsa_keypair(f.read())
|
encryption.deserialize_rsa_keypair(f.read())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _loadTenantConfigRepos(project_key_dir, connections, conf_tenant):
|
def _loadTenantProjects(project_key_dir, connections, conf_tenant):
|
||||||
config_repos = []
|
config_projects = []
|
||||||
project_repos = []
|
untrusted_projects = []
|
||||||
|
|
||||||
for source_name, conf_source in conf_tenant.get('source', {}).items():
|
for source_name, conf_source in conf_tenant.get('source', {}).items():
|
||||||
source = connections.getSource(source_name)
|
source = connections.getSource(source_name)
|
||||||
|
|
||||||
for conf_repo in conf_source.get('config-repos', []):
|
for conf_repo in conf_source.get('config-projects', []):
|
||||||
project = source.getProject(conf_repo)
|
project = source.getProject(conf_repo)
|
||||||
TenantParser._loadProjectKeys(
|
TenantParser._loadProjectKeys(
|
||||||
project_key_dir, source_name, project)
|
project_key_dir, source_name, project)
|
||||||
config_repos.append(project)
|
config_projects.append(project)
|
||||||
|
|
||||||
for conf_repo in conf_source.get('project-repos', []):
|
for conf_repo in conf_source.get('untrusted-projects', []):
|
||||||
project = source.getProject(conf_repo)
|
project = source.getProject(conf_repo)
|
||||||
TenantParser._loadProjectKeys(
|
TenantParser._loadProjectKeys(
|
||||||
project_key_dir, source_name, project)
|
project_key_dir, source_name, project)
|
||||||
project_repos.append(project)
|
untrusted_projects.append(project)
|
||||||
|
|
||||||
return config_repos, project_repos
|
return config_projects, untrusted_projects
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _loadTenantInRepoLayouts(merger, connections, config_repos,
|
def _loadTenantInRepoLayouts(merger, connections, config_projects,
|
||||||
project_repos, cached):
|
untrusted_projects, cached):
|
||||||
config_repos_config = model.UnparsedTenantConfig()
|
config_projects_config = model.UnparsedTenantConfig()
|
||||||
project_repos_config = model.UnparsedTenantConfig()
|
untrusted_projects_config = model.UnparsedTenantConfig()
|
||||||
jobs = []
|
jobs = []
|
||||||
|
|
||||||
for project in config_repos:
|
for project in config_projects:
|
||||||
# If we have cached data (this is a reconfiguration) use it.
|
# If we have cached data (this is a reconfiguration) use it.
|
||||||
if cached and project.unparsed_config:
|
if cached and project.unparsed_config:
|
||||||
TenantParser.log.info(
|
TenantParser.log.info(
|
||||||
"Loading previously parsed configuration from %s" %
|
"Loading previously parsed configuration from %s" %
|
||||||
(project,))
|
(project,))
|
||||||
config_repos_config.extend(project.unparsed_config)
|
config_projects_config.extend(project.unparsed_config)
|
||||||
continue
|
continue
|
||||||
# Otherwise, prepare an empty unparsed config object to
|
# Otherwise, prepare an empty unparsed config object to
|
||||||
# hold cached data later.
|
# hold cached data later.
|
||||||
|
@ -900,13 +900,13 @@ class TenantParser(object):
|
||||||
'', True)
|
'', True)
|
||||||
jobs.append(job)
|
jobs.append(job)
|
||||||
|
|
||||||
for project in project_repos:
|
for project in untrusted_projects:
|
||||||
# If we have cached data (this is a reconfiguration) use it.
|
# If we have cached data (this is a reconfiguration) use it.
|
||||||
if cached and project.unparsed_config:
|
if cached and project.unparsed_config:
|
||||||
TenantParser.log.info(
|
TenantParser.log.info(
|
||||||
"Loading previously parsed configuration from %s" %
|
"Loading previously parsed configuration from %s" %
|
||||||
(project,))
|
(project,))
|
||||||
project_repos_config.extend(project.unparsed_config)
|
untrusted_projects_config.extend(project.unparsed_config)
|
||||||
continue
|
continue
|
||||||
# Otherwise, prepare an empty unparsed config object to
|
# Otherwise, prepare an empty unparsed config object to
|
||||||
# hold cached data later.
|
# hold cached data later.
|
||||||
|
@ -951,27 +951,27 @@ class TenantParser(object):
|
||||||
project = job.source_context.project
|
project = job.source_context.project
|
||||||
branch = job.source_context.branch
|
branch = job.source_context.branch
|
||||||
if job.source_context.trusted:
|
if job.source_context.trusted:
|
||||||
incdata = TenantParser._parseConfigRepoLayout(
|
incdata = TenantParser._parseConfigProjectLayout(
|
||||||
job.files[fn], job.source_context)
|
job.files[fn], job.source_context)
|
||||||
config_repos_config.extend(incdata)
|
config_projects_config.extend(incdata)
|
||||||
else:
|
else:
|
||||||
incdata = TenantParser._parseProjectRepoLayout(
|
incdata = TenantParser._parseUntrustedProjectLayout(
|
||||||
job.files[fn], job.source_context)
|
job.files[fn], job.source_context)
|
||||||
project_repos_config.extend(incdata)
|
untrusted_projects_config.extend(incdata)
|
||||||
project.unparsed_config.extend(incdata)
|
project.unparsed_config.extend(incdata)
|
||||||
if branch in project.unparsed_branch_config:
|
if branch in project.unparsed_branch_config:
|
||||||
project.unparsed_branch_config[branch].extend(incdata)
|
project.unparsed_branch_config[branch].extend(incdata)
|
||||||
return config_repos_config, project_repos_config
|
return config_projects_config, untrusted_projects_config
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parseConfigRepoLayout(data, source_context):
|
def _parseConfigProjectLayout(data, source_context):
|
||||||
# This is the top-level configuration for a tenant.
|
# This is the top-level configuration for a tenant.
|
||||||
config = model.UnparsedTenantConfig()
|
config = model.UnparsedTenantConfig()
|
||||||
config.extend(safe_load_yaml(data, source_context))
|
config.extend(safe_load_yaml(data, source_context))
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parseProjectRepoLayout(data, source_context):
|
def _parseUntrustedProjectLayout(data, source_context):
|
||||||
# TODOv3(jeblair): this should implement some rules to protect
|
# TODOv3(jeblair): this should implement some rules to protect
|
||||||
# aspects of the config that should not be changed in-repo
|
# aspects of the config that should not be changed in-repo
|
||||||
config = model.UnparsedTenantConfig()
|
config = model.UnparsedTenantConfig()
|
||||||
|
@ -1061,9 +1061,8 @@ class ConfigLoader(object):
|
||||||
new_abide.tenants[tenant.name] = new_tenant
|
new_abide.tenants[tenant.name] = new_tenant
|
||||||
return new_abide
|
return new_abide
|
||||||
|
|
||||||
def _loadDynamicProjectData(self, config, project, files,
|
def _loadDynamicProjectData(self, config, project, files, trusted):
|
||||||
config_repo):
|
if trusted:
|
||||||
if config_repo:
|
|
||||||
branches = ['master']
|
branches = ['master']
|
||||||
fn = 'zuul.yaml'
|
fn = 'zuul.yaml'
|
||||||
else:
|
else:
|
||||||
|
@ -1075,29 +1074,30 @@ class ConfigLoader(object):
|
||||||
data = files.getFile(project.name, branch, fn)
|
data = files.getFile(project.name, branch, fn)
|
||||||
if data:
|
if data:
|
||||||
source_context = model.SourceContext(project, branch,
|
source_context = model.SourceContext(project, branch,
|
||||||
fn, config_repo)
|
fn, trusted)
|
||||||
if config_repo:
|
if trusted:
|
||||||
incdata = TenantParser._parseConfigRepoLayout(
|
incdata = TenantParser._parseConfigProjectLayout(
|
||||||
data, source_context)
|
data, source_context)
|
||||||
else:
|
else:
|
||||||
incdata = TenantParser._parseProjectRepoLayout(
|
incdata = TenantParser._parseUntrustedProjectLayout(
|
||||||
data, source_context)
|
data, source_context)
|
||||||
else:
|
else:
|
||||||
if config_repo:
|
if trusted:
|
||||||
incdata = project.unparsed_config
|
incdata = project.unparsed_config
|
||||||
else:
|
else:
|
||||||
incdata = project.unparsed_branch_config.get(branch)
|
incdata = project.unparsed_branch_config.get(branch)
|
||||||
if incdata:
|
if incdata:
|
||||||
config.extend(incdata)
|
config.extend(incdata)
|
||||||
|
|
||||||
def createDynamicLayout(self, tenant, files, include_config_repos=False):
|
def createDynamicLayout(self, tenant, files,
|
||||||
if include_config_repos:
|
include_config_projects=False):
|
||||||
|
if include_config_projects:
|
||||||
config = model.UnparsedTenantConfig()
|
config = model.UnparsedTenantConfig()
|
||||||
for project in tenant.config_repos:
|
for project in tenant.config_projects:
|
||||||
self._loadDynamicProjectData(config, project, files, True)
|
self._loadDynamicProjectData(config, project, files, True)
|
||||||
else:
|
else:
|
||||||
config = tenant.config_repos_config.copy()
|
config = tenant.config_projects_config.copy()
|
||||||
for project in tenant.project_repos:
|
for project in tenant.untrusted_projects:
|
||||||
self._loadDynamicProjectData(config, project, files, False)
|
self._loadDynamicProjectData(config, project, files, False)
|
||||||
|
|
||||||
layout = model.Layout()
|
layout = model.Layout()
|
||||||
|
|
|
@ -487,14 +487,14 @@ class PipelineManager(object):
|
||||||
loader.createDynamicLayout(
|
loader.createDynamicLayout(
|
||||||
item.pipeline.layout.tenant,
|
item.pipeline.layout.tenant,
|
||||||
build_set.files,
|
build_set.files,
|
||||||
include_config_repos=True)
|
include_config_projects=True)
|
||||||
|
|
||||||
# Then create the config a second time but without changes
|
# Then create the config a second time but without changes
|
||||||
# to config repos so that we actually use this config.
|
# to config repos so that we actually use this config.
|
||||||
layout = loader.createDynamicLayout(
|
layout = loader.createDynamicLayout(
|
||||||
item.pipeline.layout.tenant,
|
item.pipeline.layout.tenant,
|
||||||
build_set.files,
|
build_set.files,
|
||||||
include_config_repos=False)
|
include_config_projects=False)
|
||||||
except zuul.configloader.ConfigurationSyntaxError as e:
|
except zuul.configloader.ConfigurationSyntaxError as e:
|
||||||
self.log.info("Configuration syntax error "
|
self.log.info("Configuration syntax error "
|
||||||
"in dynamic layout %s" %
|
"in dynamic layout %s" %
|
||||||
|
|
|
@ -2512,16 +2512,16 @@ class Tenant(object):
|
||||||
# The unparsed configuration from the main zuul config for
|
# The unparsed configuration from the main zuul config for
|
||||||
# this tenant.
|
# this tenant.
|
||||||
self.unparsed_config = None
|
self.unparsed_config = None
|
||||||
# The list of repos from which we will read main
|
# The list of projects from which we will read full
|
||||||
# configuration.
|
# configuration.
|
||||||
self.config_repos = []
|
self.config_projects = []
|
||||||
# The unparsed config from those repos.
|
# The unparsed config from those projects.
|
||||||
self.config_repos_config = None
|
self.config_projects_config = None
|
||||||
# The list of projects from which we will read in-repo
|
# The list of projects from which we will read untrusted
|
||||||
# configuration.
|
# in-repo configuration.
|
||||||
self.project_repos = []
|
self.untrusted_projects = []
|
||||||
# The unparsed config from those repos.
|
# The unparsed config from those projects.
|
||||||
self.project_repos_config = None
|
self.untrusted_projects_config = None
|
||||||
self.semaphore_handler = SemaphoreHandler()
|
self.semaphore_handler = SemaphoreHandler()
|
||||||
|
|
||||||
# A mapping of project names to projects. project_name ->
|
# A mapping of project names to projects. project_name ->
|
||||||
|
@ -2579,20 +2579,20 @@ class Tenant(object):
|
||||||
"with a hostname" % (name,))
|
"with a hostname" % (name,))
|
||||||
if project is None:
|
if project is None:
|
||||||
return (None, None)
|
return (None, None)
|
||||||
if project in self.config_repos:
|
if project in self.config_projects:
|
||||||
return (True, project)
|
return (True, project)
|
||||||
if project in self.project_repos:
|
if project in self.untrusted_projects:
|
||||||
return (False, project)
|
return (False, project)
|
||||||
# This should never happen:
|
# This should never happen:
|
||||||
raise Exception("Project %s is neither trusted nor untrusted" %
|
raise Exception("Project %s is neither trusted nor untrusted" %
|
||||||
(project,))
|
(project,))
|
||||||
|
|
||||||
def addConfigRepo(self, project):
|
def addConfigProject(self, project):
|
||||||
self.config_repos.append(project)
|
self.config_projects.append(project)
|
||||||
self._addProject(project)
|
self._addProject(project)
|
||||||
|
|
||||||
def addProjectRepo(self, project):
|
def addUntrustedProject(self, project):
|
||||||
self.project_repos.append(project)
|
self.untrusted_projects.append(project)
|
||||||
self._addProject(project)
|
self._addProject(project)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue