From 1a45c57d2d2fef6e45f89d8cfb017bdc93b5d280 Mon Sep 17 00:00:00 2001 From: Adam Ruka Date: Thu, 23 May 2019 14:23:24 -0700 Subject: [PATCH] fix(codepipeline): no longer allow providing an index when adding a Stage to a Pipeline. BREAKING CHANGE: the property atIndex has been removed from the StagePlacement interface. --- .../@aws-cdk/aws-codepipeline/lib/pipeline.ts | 20 ------- .../aws-codepipeline/test/test.stages.ts | 54 ------------------- 2 files changed, 74 deletions(-) diff --git a/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts b/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts index 03622bf4fe3e0..f5f5d6e59fb88 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts @@ -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; } /** @@ -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; } diff --git a/packages/@aws-cdk/aws-codepipeline/test/test.stages.ts b/packages/@aws-cdk/aws-codepipeline/test/test.stages.ts index 81b6f703e099d..addfb552a789c 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/test.stages.ts +++ b/packages/@aws-cdk/aws-codepipeline/test/test.stages.ts @@ -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'); @@ -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');