diff --git a/app/scripts/modules/amazon/src/pipeline/stages/cloneServerGroup/awsCloneServerGroupStage.js b/app/scripts/modules/amazon/src/pipeline/stages/cloneServerGroup/awsCloneServerGroupStage.js index 2072c37347d..f9fa3bb2982 100644 --- a/app/scripts/modules/amazon/src/pipeline/stages/cloneServerGroup/awsCloneServerGroupStage.js +++ b/app/scripts/modules/amazon/src/pipeline/stages/cloneServerGroup/awsCloneServerGroupStage.js @@ -60,7 +60,7 @@ module.exports = angular.module('spinnaker.amazon.pipeline.stage.cloneServerGrou this.targetClusterUpdated = () => { if (stage.targetCluster) { - const filterByCluster = (serverGroup) => serverGroup.moniker.cluster === stage.targetCluster; + const filterByCluster = appListExtractorService.monikerClusterNameFilter(stage.targetCluster); let moniker = _.first(appListExtractorService.getMonikers([$scope.application], filterByCluster)); stage.stack = moniker.stack; stage.freeFormDetails = moniker.detail; diff --git a/app/scripts/modules/amazon/src/pipeline/stages/disableCluster/awsDisableClusterStage.js b/app/scripts/modules/amazon/src/pipeline/stages/disableCluster/awsDisableClusterStage.js index f512fabc3eb..2946087068d 100644 --- a/app/scripts/modules/amazon/src/pipeline/stages/disableCluster/awsDisableClusterStage.js +++ b/app/scripts/modules/amazon/src/pipeline/stages/disableCluster/awsDisableClusterStage.js @@ -68,4 +68,3 @@ module.exports = angular.module('spinnaker.amazon.pipeline.stage.disableClusterS } stage.preferLargerOverNewer = stage.preferLargerOverNewer.toString(); }); - diff --git a/app/scripts/modules/core/src/application/listExtractor/listExtractor.service.ts b/app/scripts/modules/core/src/application/listExtractor/listExtractor.service.ts index b4a1bc535c1..c51985ec00a 100644 --- a/app/scripts/modules/core/src/application/listExtractor/listExtractor.service.ts +++ b/app/scripts/modules/core/src/application/listExtractor/listExtractor.service.ts @@ -87,6 +87,12 @@ export class AppListExtractor { }; } + public monikerClusterNameFilter(clusterName: string): IServerGroupFilter { + return (serverGroup: IServerGroup) => { + return serverGroup.moniker.cluster === clusterName; + } + } + public clusterFilterForCredentialsAndRegion(credentials: string, region: string | string[]): IServerGroupFilter { return (serverGroup: IServerGroup) => { const accountMatches = credentials ? serverGroup.account === credentials : true; diff --git a/app/scripts/modules/core/src/pipeline/config/preconditions/selector/preconditionSelector.directive.js b/app/scripts/modules/core/src/pipeline/config/preconditions/selector/preconditionSelector.directive.js index e80698fcf55..083ca5eadde 100644 --- a/app/scripts/modules/core/src/pipeline/config/preconditions/selector/preconditionSelector.directive.js +++ b/app/scripts/modules/core/src/pipeline/config/preconditions/selector/preconditionSelector.directive.js @@ -3,6 +3,7 @@ const angular = require('angular'); import {ACCOUNT_SERVICE} from 'core/account/account.service'; import {LIST_EXTRACTOR_SERVICE} from 'core/application/listExtractor/listExtractor.service'; +import { isNil, first } from 'lodash'; module.exports = angular.module('spinnaker.core.pipeline.config.preconditions.selector', [ ACCOUNT_SERVICE, @@ -45,6 +46,16 @@ module.exports = angular.module('spinnaker.core.pipeline.config.preconditions.se return preconditionConfig ? preconditionConfig.contextTemplateUrl : ''; }; + this.clusterChanged = function (clusterName) { + let clusterFilter = appListExtractorService.monikerClusterNameFilter(clusterName); + let moniker = first(appListExtractorService.getMonikers([$scope.application], clusterFilter)); + if (!isNil(moniker)) { + //cluster monikers dont have sequences + moniker.sequence = undefined; + } + $scope.precondition.context.moniker = moniker; + }; + let setClusterList = () => { let clusterFilter = appListExtractorService.clusterFilterForCredentialsAndRegion($scope.precondition.context.credentials, $scope.precondition.context.regions); $scope.clusterList = appListExtractorService.getClusters([$scope.application], clusterFilter); @@ -52,6 +63,7 @@ module.exports = angular.module('spinnaker.core.pipeline.config.preconditions.se this.resetSelectedCluster = () => { $scope.precondition.context.cluster = undefined; + $scope.precondition.context.moniker = undefined; setClusterList(); }; diff --git a/app/scripts/modules/core/src/pipeline/config/preconditions/types/clusterSize/additionalFields.html b/app/scripts/modules/core/src/pipeline/config/preconditions/types/clusterSize/additionalFields.html index 3ec56437425..6c71300d639 100644 --- a/app/scripts/modules/core/src/pipeline/config/preconditions/types/clusterSize/additionalFields.html +++ b/app/scripts/modules/core/src/pipeline/config/preconditions/types/clusterSize/additionalFields.html @@ -28,7 +28,8 @@