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. """
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
<div class="tbd-content" ng-switch-when="commitsha">
|
||||
Triggered by commit
|
||||
<span class="source-commit-link"
|
||||
commit-sha="build.trigger_metadata.commit"></span>
|
||||
commit-sha="TriggerService.getCommitSHA(build.trigger_metadata)"></span>
|
||||
</div>
|
||||
|
||||
<!-- Full Commit Information -->
|
||||
<div class="tbd-content" ng-switch-when="fullcommit">
|
||||
<div class="commit-message">
|
||||
<span class="anchor" is-only-text="!TriggerService.getFullLinkTemplate(build, 'commit')"
|
||||
target="_blank" href="{{ TriggerService.getFullLinkTemplate(build, 'commit').replace('{sha}', build.trigger_metadata.commit) }}">
|
||||
target="_blank" href="{{ TriggerService.getFullLinkTemplate(build, 'commit').replace('{sha}', TriggerService.getCommitSHA(build.trigger_metadata)) }}">
|
||||
{{ build.trigger_metadata.commit_info.message }}
|
||||
</span>
|
||||
</div>
|
||||
|
@ -46,7 +46,7 @@
|
|||
</span>
|
||||
</span>
|
||||
<span class="source-commit-link"
|
||||
commit-sha="build.trigger_metadata.commit"
|
||||
commit-sha="TriggerService.getCommitSHA(build.trigger_metadata)"
|
||||
url-template="TriggerService.getFullLinkTemplate(build, 'commit')"></span>
|
||||
<span class="source-ref-link"
|
||||
ref="build.trigger_metadata.ref"
|
||||
|
|
|
@ -45,7 +45,7 @@ angular.module('quay').directive('repoPanelBuilds', function () {
|
|||
var commit_sha = null;
|
||||
|
||||
if (build_info.trigger_metadata) {
|
||||
commit_sha = build_info.trigger_metadata.commit;
|
||||
commit_sha = TriggerService.getCommitSHA(build_info.trigger_metadata);
|
||||
}
|
||||
|
||||
return $.extend(build_info, {
|
||||
|
|
|
@ -33,7 +33,7 @@ angular.module('quay').directive('triggeredBuildDescription', function () {
|
|||
return;
|
||||
}
|
||||
|
||||
if (build.trigger && build.trigger.build_source && triggerMetadata.commit) {
|
||||
if (build.trigger && build.trigger.build_source && TriggerService.getCommitSHA(triggerMetadata)) {
|
||||
$scope.infoDisplay = 'commitsha';
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -252,6 +252,10 @@ angular.module('quay').factory('TriggerService', ['UtilService', '$sanitize', 'K
|
|||
return desc;
|
||||
};
|
||||
|
||||
triggerService.getCommitSHA = function(metadata) {
|
||||
return metadata.commit || metadata.commit_sha;
|
||||
};
|
||||
|
||||
triggerService.getMetadata = function(name) {
|
||||
return triggerTypes[name];
|
||||
};
|
||||
|
|
Reference in a new issue