Skip to content

Commit

Permalink
feat(provider/ecs): Added DestroyAsg pipeline stage (#4399)
Browse files Browse the repository at this point in the history
* feat(provider/ecs): Added DestroyAsg pipeline stage

* Removed executionDetailsUrl property

* removed unused import
  • Loading branch information
BrunoCarrier authored and Justin Reynolds committed Nov 15, 2017
1 parent 884e7ac commit 3aab921
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
@@ -0,0 +1,12 @@
<div ng-controller="ecsDestroyAsgStageCtrl as destroyAsgStageCtrl" class="form-horizontal">
<div ng-if="!pipeline.strategy">
<account-region-cluster-selector
application="application"
component="stage"
accounts="accounts" >
</account-region-cluster-selector>
</div>
<stage-config-field label="Target">
<target-select model="stage" options="targets"></target-select>
</stage-config-field>
</div>
@@ -0,0 +1,5 @@
<span class="task-label">
Destroy Server Group:
{{step.context.serverGroupName}}
({{step.context.region}})
</span>
@@ -0,0 +1,61 @@
'use strict';

const angular = require('angular');

import { StageConstants } from '@spinnaker/core';

module.exports = angular.module('spinnaker.ecs.pipeline.stage.ecs.destroyAsgStage', [])
.config(function(pipelineConfigProvider) {
pipelineConfigProvider.registerStage({
provides: 'destroyServerGroup',
alias: 'destroyAsg',
cloudProvider: 'ecs',
templateUrl: require('./destroyAsgStage.html'),
executionStepLabelUrl: require('./destroyAsgStepLabel.html'),
accountExtractor: (stage) => [stage.context.credentials],
configAccountExtractor: (stage) => [stage.credentials],
validators: [
{
type: 'targetImpedance',
message: 'This pipeline will attempt to destroy a server group without deploying a new version into the same cluster.'
},
{ type: 'requiredField', fieldName: 'cluster' },
{ type: 'requiredField', fieldName: 'target', },
{ type: 'requiredField', fieldName: 'regions', },
{ type: 'requiredField', fieldName: 'credentials', fieldLabel: 'account'},
],
});
}).controller('ecsDestroyAsgStageCtrl', function($scope, accountService) {

let stage = $scope.stage;

$scope.state = {
accounts: false,
regionsLoaded: false
};

accountService.listAccounts('ecs').then(function (accounts) {
$scope.accounts = accounts;
$scope.state.accounts = true;
});

$scope.regions = ['us-east-1', 'us-west-1', 'eu-west-1', 'us-west-2'];

$scope.targets = StageConstants.TARGET_LIST;

stage.regions = stage.regions || [];
stage.cloudProvider = 'ecs';

if (!stage.credentials && $scope.application.defaultCredentials.ecs) {
stage.credentials = $scope.application.defaultCredentials.ecs;
}
if (!stage.regions.length && $scope.application.defaultRegions.ecs) {
stage.regions.push($scope.application.defaultRegions.ecs);
}

if (!stage.target) {
stage.target = $scope.targets[0].val;
}

});

0 comments on commit 3aab921

Please sign in to comment.