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
parent cb6a48a553
commit 8c5f40229c
2 changed files with 10 additions and 2 deletions

View File

@ -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,

View File

@ -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