Merge "Don't exclude config if excluded in earlier tenant"
This commit is contained in:
commit
aa115f6932
|
@ -0,0 +1,21 @@
|
||||||
|
- tenant:
|
||||||
|
name: tenant-one
|
||||||
|
source:
|
||||||
|
gerrit:
|
||||||
|
config-projects:
|
||||||
|
- common-config
|
||||||
|
untrusted-projects:
|
||||||
|
- org/project1:
|
||||||
|
include: []
|
||||||
|
- org/project2
|
||||||
|
|
||||||
|
- tenant:
|
||||||
|
name: tenant-two
|
||||||
|
source:
|
||||||
|
gerrit:
|
||||||
|
config-projects:
|
||||||
|
- common-config
|
||||||
|
untrusted-projects:
|
||||||
|
- org/project1
|
||||||
|
- org/project2
|
||||||
|
- org/project5
|
|
@ -0,0 +1,3 @@
|
||||||
|
- job:
|
||||||
|
name: project5-job
|
||||||
|
parent: project1-job
|
|
@ -312,6 +312,22 @@ class TestTenantUnprotectedBranches(TenantParserTestCase):
|
||||||
self.assertIsNone(tpc[project_name].exclude_unprotected_branches)
|
self.assertIsNone(tpc[project_name].exclude_unprotected_branches)
|
||||||
|
|
||||||
|
|
||||||
|
class TestTenantExcludeAll(TenantParserTestCase):
|
||||||
|
tenant_config_file = 'config/tenant-parser/exclude-all.yaml'
|
||||||
|
|
||||||
|
def test_tenant_exclude_all(self):
|
||||||
|
"""
|
||||||
|
Tests that excluding all configuration of project1 in tenant-one
|
||||||
|
doesn't remove the configuration of project1 in tenant-two.
|
||||||
|
"""
|
||||||
|
# The config in org/project5 depends on config in org/project1 so
|
||||||
|
# validate that there are no config errors in that tenant.
|
||||||
|
tenant_two = self.sched.abide.tenants.get('tenant-two')
|
||||||
|
self.assertEquals(
|
||||||
|
len(tenant_two.layout.loading_errors), 0,
|
||||||
|
"No error should have been accumulated")
|
||||||
|
|
||||||
|
|
||||||
class TestSplitConfig(ZuulTestCase):
|
class TestSplitConfig(ZuulTestCase):
|
||||||
tenant_config_file = 'config/split-config/main.yaml'
|
tenant_config_file = 'config/split-config/main.yaml'
|
||||||
|
|
||||||
|
|
|
@ -1563,8 +1563,9 @@ class TenantParser(object):
|
||||||
# in-repo configuration apply only to that branch.
|
# in-repo configuration apply only to that branch.
|
||||||
branches = tenant.getProjectBranches(project)
|
branches = tenant.getProjectBranches(project)
|
||||||
for branch in branches:
|
for branch in branches:
|
||||||
if abide.getUnparsedConfig(project.canonical_name,
|
unparsed_config = abide.getUnparsedConfig(
|
||||||
branch):
|
project.canonical_name, branch)
|
||||||
|
if unparsed_config and not unparsed_config.load_skipped:
|
||||||
# We already have this branch cached.
|
# We already have this branch cached.
|
||||||
continue
|
continue
|
||||||
if not tpc.load_classes:
|
if not tpc.load_classes:
|
||||||
|
@ -1573,7 +1574,7 @@ class TenantParser(object):
|
||||||
# data so we know we've looked at this branch.
|
# data so we know we've looked at this branch.
|
||||||
abide.cacheUnparsedConfig(
|
abide.cacheUnparsedConfig(
|
||||||
project.canonical_name,
|
project.canonical_name,
|
||||||
branch, model.UnparsedConfig())
|
branch, model.UnparsedConfig(load_skipped=True))
|
||||||
continue
|
continue
|
||||||
job = self.merger.getFiles(
|
job = self.merger.getFiles(
|
||||||
project.source.connection.connection_name,
|
project.source.connection.connection_name,
|
||||||
|
|
|
@ -3218,7 +3218,7 @@ class UnparsedAbideConfig(object):
|
||||||
class UnparsedConfig(object):
|
class UnparsedConfig(object):
|
||||||
"""A collection of yaml lists that has not yet been parsed into objects."""
|
"""A collection of yaml lists that has not yet been parsed into objects."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, load_skipped=False):
|
||||||
self.pragmas = []
|
self.pragmas = []
|
||||||
self.pipelines = []
|
self.pipelines = []
|
||||||
self.jobs = []
|
self.jobs = []
|
||||||
|
@ -3228,6 +3228,10 @@ class UnparsedConfig(object):
|
||||||
self.secrets = []
|
self.secrets = []
|
||||||
self.semaphores = []
|
self.semaphores = []
|
||||||
|
|
||||||
|
# This indicates wether this is empty because we skipped loading
|
||||||
|
# earlier because all config items have been excluded.
|
||||||
|
self.load_skipped = load_skipped
|
||||||
|
|
||||||
def copy(self, trusted=None):
|
def copy(self, trusted=None):
|
||||||
# If trusted is not None, update the source context of each
|
# If trusted is not None, update the source context of each
|
||||||
# object in the copy.
|
# object in the copy.
|
||||||
|
|
Loading…
Reference in New Issue