Skip to content

Commit

Permalink
fix(codepipeline): no longer allow providing an index when adding a S…
Browse files Browse the repository at this point in the history
…tage to a Pipeline. (#2624)

Removed at the CodePipeline team's request.

BREAKING CHANGE: the property atIndex has been removed from the StagePlacement interface.
  • Loading branch information
skinny85 committed May 24, 2019
1 parent 9c58d6f commit ce39b12
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 74 deletions.
20 changes: 0 additions & 20 deletions packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ export interface StagePlacement {
* (changing its current child Stage, if it had one).
*/
readonly justAfter?: IStage;

/**
* Inserts the new Stage at the given index in the Pipeline,
* moving the Stage currently at that index,
* and any subsequent ones, one index down.
* Indexing starts at 0.
* The maximum allowed value is {@link Pipeline#stageCount},
* which will insert the new Stage at the end of the Pipeline.
*/
readonly atIndex?: number;
}

/**
Expand Down Expand Up @@ -435,16 +425,6 @@ export class Pipeline extends PipelineBase {
return targetIndex + 1;
}

if (placement.atIndex !== undefined) {
const index = placement.atIndex;
if (index < 0 || index > this.stageCount) {
throw new Error("Error adding Stage to the Pipeline: " +
`{ placed: atIndex } should be between 0 and the number of stages in the Pipeline (${this.stageCount}), ` +
` got: ${index}`);
}
return index;
}

return this.stageCount;
}

Expand Down
54 changes: 0 additions & 54 deletions packages/@aws-cdk/aws-codepipeline/test/test.stages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,6 @@ import codepipeline = require('../lib');

export = {
'Pipeline Stages': {
'can be inserted at index 0'(test: Test) {
const stack = new cdk.Stack();
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');

pipeline.addStage({ name: 'SecondStage' });
pipeline.addStage({
name: 'FirstStage',
placement: {
atIndex: 0,
},
});

expect(stack, true).to(haveResourceLike('AWS::CodePipeline::Pipeline', {
"Stages": [
{ "Name": "FirstStage" },
{ "Name": "SecondStage" },
],
}));

test.done();
},

'can be inserted before another Stage'(test: Test) {
const stack = new cdk.Stack();
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');
Expand Down Expand Up @@ -75,38 +53,6 @@ export = {
test.done();
},

'attempting to insert a Stage at a negative index results in an error'(test: Test) {
const stack = new cdk.Stack();
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');

test.throws(() => {
pipeline.addStage({
name: 'Stage',
placement: {
atIndex: -1,
},
});
}, /atIndex/);

test.done();
},

'attempting to insert a Stage at an index larger than the current number of Stages results in an error'(test: Test) {
const stack = new cdk.Stack();
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');

test.throws(() => {
pipeline.addStage({
name: 'Stage',
placement: {
atIndex: 1,
},
});
}, /atIndex/);

test.done();
},

"attempting to insert a Stage before a Stage that doesn't exist results in an error"(test: Test) {
const stack = new cdk.Stack();
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');
Expand Down

0 comments on commit ce39b12

Please sign in to comment.