triggers: backwards compatible schema for metadata
This commit is contained in:
parent
e01bdd4ab0
commit
7f4dd7d42f
5 changed files with 18 additions and 6 deletions
|
@ -139,7 +139,7 @@ class BuildComponent(BaseComponent):
|
|||
if build_job.repo_build.trigger.private_key is not None:
|
||||
build_arguments['git'] = {
|
||||
'url': build_config['trigger_metadata'].get('git_url', ''),
|
||||
'sha': build_config['trigger_metadata'].get('commit', ''),
|
||||
'sha': BuildComponent._commit_sha(build_config),
|
||||
'private_key': build_job.repo_build.trigger.private_key,
|
||||
}
|
||||
|
||||
|
@ -149,6 +149,14 @@ class BuildComponent(BaseComponent):
|
|||
|
||||
self.call("io.quay.builder.build", **build_arguments).add_done_callback(self._build_complete)
|
||||
|
||||
@staticmethod
|
||||
def _commit_sha(build_config):
|
||||
""" Determines whether the metadata is using an old schema or not and returns the commit. """
|
||||
commit_sha = build_config['trigger_metadata'].get('commit', '')
|
||||
old_commit_sha = build_config['trigger_metadata'].get('commit_sha', '')
|
||||
return commit_sha or old_commit_sha
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _total_completion(statuses, total_images):
|
||||
""" Returns the current amount completion relative to the total completion of a build. """
|
||||
|
|
Reference in a new issue