Skip to content

Commit

Permalink
fix(pipelines): consider providesFor field when selecting stage provider
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherchrisberry committed Mar 2, 2017
1 parent ade3f19 commit 5cf440f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Expand Up @@ -26,7 +26,15 @@ module.exports = angular.module('spinnaker.core.pipeline.stage.baseProviderStage

accountService.listProviders($scope.application).then(function (providers) {
$scope.viewState.loading = false;
var availableProviders = _.intersection(providers, _.map(stageProviders, 'cloudProvider'));
const availableProviders = [];
stageProviders.forEach(sp => {
if (sp.cloudProvider && providers.includes(sp.cloudProvider)) {
// default to the specified cloud provider if the app supports it
availableProviders.push(sp.cloudProvider);
} else if (sp.providesFor) {
availableProviders.push(...sp.providesFor.filter(p => providers.includes(p)));
}
});
if (dockerBakeEnabled) {
availableProviders.push('docker');
}
Expand All @@ -41,7 +49,8 @@ module.exports = angular.module('spinnaker.core.pipeline.stage.baseProviderStage
});

function loadProvider() {
var stageProvider = _.find(stageProviders, { cloudProvider: stage.cloudProviderType });
const stageProvider = (stageProviders || [])
.find(s => s.cloudProvider === stage.cloudProviderType || (s.providesFor || []).includes(stage.cloudProviderType));
if (stageProvider) {
$scope.stage.type = stageProvider.key || $scope.stage.type;
$scope.providerStageDetailsUrl = stageProvider.templateUrl;
Expand Down
Expand Up @@ -11,7 +11,6 @@ module.exports = angular.module('spinnaker.core.pipeline.stage.titus.titusBakeSt
provides: 'bake',
useBaseProvider: true,
cloudProvider: 'titus',
providesFor: ['titus'],
templateUrl: require('./bakeStage.html'),
executionDetailsUrl: require('./bakeExecutionDetails.html'),
validators: []
Expand Down
Expand Up @@ -10,7 +10,7 @@ module.exports = angular.module('spinnaker.core.pipeline.stage.titus.runJobStage
pipelineConfigProvider.registerStage({
provides: 'runJob',
useBaseProvider: true,
cloudProvider: 'aws',
cloudProvider: 'titus',
providesFor: ['aws', 'titus'],
templateUrl: require('./runJobStage.html'),
executionDetailsUrl: require('./runJobExecutionDetails.html'),
Expand Down

0 comments on commit 5cf440f

Please sign in to comment.