Add config metadata to identify project-templates
Since project default branches were fixed in Iddd5ef906c2bdbcc472615ffe25033c4ca961df7 the workaround in the project detail view of the dashboard to distinguish actual project configs from project-template configs will no longer work. Extend the config model to incorporate a flag which indicates whether it comes from a template or an actual project directly, and use that in the dashboard rather than a (now broken) proxy value. Change-Id: I2958a9bb01ca5261604773de742b6b652fca4cae
This commit is contained in:
parent
318df3a9ba
commit
6ec55d9f39
|
@ -847,6 +847,7 @@ class TestWeb(BaseTestWeb):
|
|||
'connection_name': 'gerrit',
|
||||
'name': 'org/project1',
|
||||
'metadata': {
|
||||
'is_template': False,
|
||||
'default_branch': 'master',
|
||||
'merge_mode': 'merge-resolve',
|
||||
'queue_name': 'integrated',
|
||||
|
@ -855,6 +856,7 @@ class TestWeb(BaseTestWeb):
|
|||
'source_context': {'branch': 'master',
|
||||
'path': 'zuul.yaml',
|
||||
'project': 'common-config'},
|
||||
'is_template': False,
|
||||
'templates': [],
|
||||
'default_branch': None,
|
||||
'queue_name': 'integrated',
|
||||
|
|
|
@ -28,7 +28,7 @@ export const receiveProject = (tenant, projectName, project) => {
|
|||
const templateIdx = []
|
||||
let idx
|
||||
project.configs.forEach((config, idx) => {
|
||||
if (config.default_branch === null) {
|
||||
if (config.is_template === true) {
|
||||
// This must be a template
|
||||
templateIdx.push(idx)
|
||||
config.pipelines.forEach(templatePipeline => {
|
||||
|
|
|
@ -1162,6 +1162,7 @@ class ProjectTemplateParser(object):
|
|||
project_template = model.ProjectConfig(conf.get('name'))
|
||||
project_template.source_context = conf['_source_context']
|
||||
project_template.start_mark = conf['_start_mark']
|
||||
project_template.is_template = True
|
||||
project_template.queue_name = conf.get('queue')
|
||||
for pipeline_name, conf_pipeline in conf.items():
|
||||
if pipeline_name in self.not_pipelines:
|
||||
|
@ -1284,6 +1285,10 @@ class ProjectParser(object):
|
|||
|
||||
project_config.name = project.canonical_name
|
||||
|
||||
# Explicitly override this to False since we're reusing the
|
||||
# project-template loading method which sets it True.
|
||||
project_config.is_template = False
|
||||
|
||||
# Pragmas can cause templates to end up with implied
|
||||
# branch matchers for arbitrary branches, but project
|
||||
# stanzas should not. They should either have the current
|
||||
|
|
|
@ -7313,6 +7313,7 @@ class ProjectConfig(ConfigObject):
|
|||
def __init__(self, name):
|
||||
super(ProjectConfig, self).__init__()
|
||||
self.name = name
|
||||
self.is_template = False
|
||||
self.templates = []
|
||||
# Pipeline name -> ProjectPipelineConfig
|
||||
self.pipelines = {}
|
||||
|
@ -7334,6 +7335,7 @@ class ProjectConfig(ConfigObject):
|
|||
r = self.__class__(self.name)
|
||||
r.source_context = self.source_context
|
||||
r.start_mark = self.start_mark
|
||||
r.is_template = self.is_template
|
||||
r.templates = self.templates
|
||||
r.pipelines = self.pipelines
|
||||
r.branch_matcher = self.branch_matcher
|
||||
|
@ -7365,6 +7367,7 @@ class ProjectConfig(ConfigObject):
|
|||
MERGER_MAP.items()))[0][0]
|
||||
else:
|
||||
d['merge_mode'] = None
|
||||
d['is_template'] = self.is_template
|
||||
d['templates'] = self.templates
|
||||
d['queue_name'] = self.queue_name
|
||||
return d
|
||||
|
@ -7381,6 +7384,7 @@ class ProjectMetadata:
|
|||
def __init__(self):
|
||||
self.merge_mode = None
|
||||
self._default_branch = None
|
||||
self.is_template = False
|
||||
self.queue_name = None
|
||||
|
||||
def isDefaultBranchSet(self):
|
||||
|
@ -7398,6 +7402,7 @@ class ProjectMetadata:
|
|||
return {
|
||||
'merge_mode': self.merge_mode,
|
||||
'default_branch': self.default_branch,
|
||||
'is_template': self.is_template,
|
||||
'queue_name': self.queue_name,
|
||||
}
|
||||
|
||||
|
@ -7406,6 +7411,7 @@ class ProjectMetadata:
|
|||
o = cls()
|
||||
o.merge_mode = data['merge_mode']
|
||||
o.default_branch = data['default_branch']
|
||||
o.is_template = data['is_template']
|
||||
o.queue_name = data['queue_name']
|
||||
return o
|
||||
|
||||
|
|
Loading…
Reference in New Issue