-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathwave.ts
120 lines (106 loc) · 2.52 KB
/
wave.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import * as cdk from '@aws-cdk/core';
import { StageDeployment } from './stage-deployment';
import { StackSteps, Step } from './step';
/**
* Construction properties for a `Wave`
*/
export interface WaveProps {
/**
* Additional steps to run before any of the stages in the wave
*
* @default - No additional steps
*/
readonly pre?: Step[];
/**
* Additional steps to run after all of the stages in the wave
*
* @default - No additional steps
*/
readonly post?: Step[];
}
/**
* Multiple stages that are deployed in parallel
*/
export class Wave {
/**
* Additional steps that are run before any of the stages in the wave
*/
public readonly pre: Step[];
/**
* Additional steps that are run after all of the stages in the wave
*/
public readonly post: Step[];
/**
* The stages that are deployed in this wave
*/
public readonly stages: StageDeployment[] = [];
constructor(
/** Identifier for this Wave */
public readonly id: string, props: WaveProps = {}) {
this.pre = props.pre ?? [];
this.post = props.post ?? [];
}
/**
* Add a Stage to this wave
*
* It will be deployed in parallel with all other stages in this
* wave.
*/
public addStage(stage: cdk.Stage, options: AddStageOpts = {}) {
const ret = StageDeployment.fromStage(stage, options);
this.stages.push(ret);
return ret;
}
/**
* Add an additional step to run before any of the stages in this wave
*/
public addPre(...steps: Step[]) {
this.pre.push(...steps);
}
/**
* Add an additional step to run after all of the stages in this wave
*/
public addPost(...steps: Step[]) {
this.post.push(...steps);
}
}
/**
* Options to pass to `addStage`
*/
export interface AddStageOpts {
/**
* Additional steps to run before any of the stacks in the stage
*
* @default - No additional steps
*/
readonly pre?: Step[];
/**
* Additional steps to run after all of the stacks in the stage
*
* @default - No additional steps
*/
readonly post?: Step[];
/**
* Instructions for stack level steps
*
* @default - No additional instructions
*/
readonly stackSteps?: StackSteps[];
}
/**
* Options to pass to `addWave`
*/
export interface WaveOptions {
/**
* Additional steps to run before any of the stages in the wave
*
* @default - No additional steps
*/
readonly pre?: Step[];
/**
* Additional steps to run after all of the stages in the wave
*
* @default - No additional steps
*/
readonly post?: Step[];
}