Bug 1551738: Add a helper to extract the task name from the final task; r=Callek

Differential Revision: https://phabricator.services.mozilla.com/D31160

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Prince 2019-05-15 18:04:47 +00:00
Родитель cb6a48a553
Коммит 8c5f40229c
2 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -46,6 +46,15 @@ class Task(object):
def __attrs_post_init__(self):
self.attributes['kind'] = self.kind
@property
def name(self):
if self.label.startswith(self.kind + "-"):
return self.label[len(self.kind)+1:]
elif self.label.startswith("build-docker-image-"):
return self.label[len("build-docker-image-"):]
else:
raise AttributeError("Task {} does not have a name.".format(self.label))
def to_json(self):
rv = {
'kind': self.kind,

Просмотреть файл

@ -187,8 +187,7 @@ def setup_name(config, jobs):
dep = job['primary-dependency']
# Set the name to the same as the dep task, without kind name.
# Label will get set automatically with this kinds name.
job['name'] = job.get('name',
dep.task['metadata']['name'][len(dep.kind) + 1:])
job['name'] = job.get('name', dep.name)
yield job