From 7f4dd7d42f9fc8bd1687c938b879e09154d93a49 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Tue, 2 Jun 2015 15:43:55 -0400 Subject: [PATCH] triggers: backwards compatible schema for metadata --- buildman/component/buildcomponent.py | 10 +++++++++- static/directives/triggered-build-description.html | 6 +++--- static/js/directives/repo-view/repo-panel-builds.js | 2 +- static/js/directives/ui/triggered-build-description.js | 2 +- static/js/services/trigger-service.js | 4 ++++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/buildman/component/buildcomponent.py b/buildman/component/buildcomponent.py index 96afc6821..c4c8544d1 100644 --- a/buildman/component/buildcomponent.py +++ b/buildman/component/buildcomponent.py @@ -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. """ diff --git a/static/directives/triggered-build-description.html b/static/directives/triggered-build-description.html index 0ca5af364..1339df82b 100644 --- a/static/directives/triggered-build-description.html +++ b/static/directives/triggered-build-description.html @@ -21,14 +21,14 @@
Triggered by commit + commit-sha="TriggerService.getCommitSHA(build.trigger_metadata)">
+ target="_blank" href="{{ TriggerService.getFullLinkTemplate(build, 'commit').replace('{sha}', TriggerService.getCommitSHA(build.trigger_metadata)) }}"> {{ build.trigger_metadata.commit_info.message }}
@@ -46,7 +46,7 @@