Merge "Add _projects to convert project list to dictionary" into feature/zuulv3

This commit is contained in:
Zuul 2017-10-19 15:28:17 +00:00 committed by Gerrit Code Review
commit 8b04895e51
2 changed files with 20 additions and 2 deletions

View File

@ -249,6 +249,13 @@ of item.
A boolean indicating whether this project appears in the
:attr:`job.required-projects` list for this job.
.. var:: _projects
:type: dict
The same as ``projects`` but a dictionary indexed by the
``name`` value of each entry. ``projects`` will be converted to
this.
.. var:: tenant
The name of the current Zuul tenant.

View File

@ -187,6 +187,7 @@ class ExecutorClient(object):
and item.change.newrev != '0' * 40):
zuul_params['newrev'] = item.change.newrev
zuul_params['projects'] = [] # Set below
zuul_params['_projects'] = {} # transitional to convert to dict
zuul_params['items'] = []
for i in all_items:
d = dict()
@ -270,14 +271,24 @@ class ExecutorClient(object):
projects.add(project)
for p in projects:
zuul_params['projects'].append(dict(
zuul_params['_projects'][p.canonical_name] = (dict(
name=p.name,
short_name=p.name.split('/')[-1],
canonical_hostname=p.canonical_hostname,
# Duplicate this into the dict too, so that iterating
# project.values() is easier for callers
canonical_name=p.canonical_name,
canonical_hostname=p.canonical_hostname,
src_dir=os.path.join('src', p.canonical_name),
required=(p in required_projects),
))
# We are transitioning "projects" from a list to a dict
# indexed by canonical name, as it is much easier to access
# values in ansible. Existing callers are converted to
# "_projects", then once "projects" is unused we switch it,
# then convert callers back. Finally when "_projects" is
# unused it will be removed.
for cn, p in zuul_params['_projects'].items():
zuul_params['projects'].append(p)
build = Build(job, uuid)
build.parameters = params