@spinnaker/kubernetes 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,13 +16,17 @@ export interface IManifestDeploymentOptionsProps {
16
16
  config: ITrafficManagementConfig;
17
17
  onConfigChange: (config: ITrafficManagementConfig) => void;
18
18
  selectedAccount: string;
19
+ isDeploymentKind: boolean;
19
20
  }
20
21
  export interface IManifestDeploymentOptionsState {
21
22
  services: string[];
23
+ showRedBlackWarningMessage: boolean;
24
+ showBlueGreenDeploymentWarningMessage: boolean;
22
25
  }
23
26
  export declare class ManifestDeploymentOptions extends React.Component<IManifestDeploymentOptionsProps, IManifestDeploymentOptionsState> {
24
27
  state: IManifestDeploymentOptionsState;
25
28
  private onConfigChange;
29
+ private updateProps;
26
30
  private fetchServices;
27
31
  private getServiceOptions;
28
32
  private strategyOptionRenderer;
@@ -0,0 +1,2 @@
1
+ import type { IDeploymentStrategy } from '@spinnaker/core';
2
+ export declare const strategyBlueGreen: IDeploymentStrategy;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spinnaker/kubernetes",
3
3
  "license": "Apache-2.0",
4
- "version": "0.3.1",
4
+ "version": "0.4.0",
5
5
  "module": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "lib": "npm run build"
14
14
  },
15
15
  "dependencies": {
16
- "@spinnaker/core": "^0.22.1",
16
+ "@spinnaker/core": "^0.23.0",
17
17
  "@uirouter/angularjs": "1.0.26",
18
18
  "@uirouter/react": "1.0.7",
19
19
  "angular": "1.6.10",
@@ -50,5 +50,5 @@
50
50
  "shx": "0.3.3",
51
51
  "typescript": "4.3.5"
52
52
  },
53
- "gitHead": "e6411725682850767e058ddb5d1cab16c246905a"
53
+ "gitHead": "4d61e53884040e8cae45d29b398c88e3814c6aca"
54
54
  }
@@ -192,6 +192,7 @@ export class DeployManifestStageForm extends React.Component<
192
192
  config={stage.trafficManagement}
193
193
  onConfigChange={(config) => this.props.formik.setFieldValue('trafficManagement', config)}
194
194
  selectedAccount={stage.account}
195
+ isDeploymentKind={this.state.rawManifest.includes('kind: Deployment')}
195
196
  />
196
197
  </div>
197
198
  );
@@ -17,6 +17,7 @@ describe('<ManifestDeploymentOptions />', () => {
17
17
  config: defaultTrafficManagementConfig,
18
18
  onConfigChange: onConfigChangeSpy,
19
19
  selectedAccount: null,
20
+ isDeploymentKind: null,
20
21
  };
21
22
  wrapper = shallow(<ManifestDeploymentOptions {...props} />);
22
23
  });
@@ -49,5 +50,41 @@ describe('<ManifestDeploymentOptions />', () => {
49
50
  wrapper = shallow(<ManifestDeploymentOptions {...props} />);
50
51
  expect(wrapper.find('input[type="checkbox"]').at(1).props().disabled).toEqual(true);
51
52
  });
53
+ it('disables the traffic checkbox when blue/green rollout strategy is selected', () => {
54
+ props.config.options.strategy = 'bluegreen';
55
+ wrapper = shallow(<ManifestDeploymentOptions {...props} />);
56
+ expect(wrapper.find('input[type="checkbox"]').at(1).props().disabled).toEqual(true);
57
+ });
58
+
59
+ it('strategy bluegreen should not display warning label', () => {
60
+ props.config.options.strategy = 'bluegreen';
61
+ wrapper = shallow(<ManifestDeploymentOptions {...props} />);
62
+ expect(wrapper.find('p[id="redBlackWarning"]').exists()).toEqual(false);
63
+ });
64
+ it('strategy highlander should not display warning label', () => {
65
+ props.config.options.strategy = 'highlander';
66
+ wrapper = shallow(<ManifestDeploymentOptions {...props} />);
67
+ expect(wrapper.find('p[id="redBlackWarning"]').exists()).toEqual(false);
68
+ });
69
+
70
+ it('strategy redblack should display warning label', () => {
71
+ props.config.options.strategy = 'redblack';
72
+ wrapper = shallow(<ManifestDeploymentOptions {...props} />);
73
+ expect(wrapper.find('p[id="redBlackWarning"]').exists()).toEqual(true);
74
+ });
75
+
76
+ it('strategy bluegreen with deployment kind should display warning label', () => {
77
+ props.config.options.strategy = 'bluegreen';
78
+ props.isDeploymentKind = true;
79
+ wrapper = shallow(<ManifestDeploymentOptions {...props} />);
80
+ expect(wrapper.find('p[id="blueGreenWarning"]').exists()).toEqual(true);
81
+ });
82
+
83
+ it('strategy bluegreen with replicaSet kind should not display warning label', () => {
84
+ props.config.options.strategy = 'bluegreen';
85
+ props.isDeploymentKind = false;
86
+ wrapper = shallow(<ManifestDeploymentOptions {...props} />);
87
+ expect(wrapper.find('p[id="blueGreenWarning"]').exists()).toEqual(false);
88
+ });
52
89
  });
53
90
  });
@@ -37,23 +37,42 @@ export interface IManifestDeploymentOptionsProps {
37
37
  config: ITrafficManagementConfig;
38
38
  onConfigChange: (config: ITrafficManagementConfig) => void;
39
39
  selectedAccount: string;
40
+ isDeploymentKind: boolean;
40
41
  }
41
42
 
42
43
  export interface IManifestDeploymentOptionsState {
43
44
  services: string[];
45
+ showRedBlackWarningMessage: boolean;
46
+ showBlueGreenDeploymentWarningMessage: boolean;
44
47
  }
45
48
 
46
49
  export class ManifestDeploymentOptions extends React.Component<
47
50
  IManifestDeploymentOptionsProps,
48
51
  IManifestDeploymentOptionsState
49
52
  > {
50
- public state: IManifestDeploymentOptionsState = { services: [] };
53
+ public state: IManifestDeploymentOptionsState = {
54
+ services: [],
55
+ showRedBlackWarningMessage: false,
56
+ showBlueGreenDeploymentWarningMessage: false,
57
+ };
51
58
 
52
59
  private onConfigChange = (key: string, value: any): void => {
60
+ this.setState({ showRedBlackWarningMessage: false });
61
+ if (value === 'redblack') {
62
+ value = 'bluegreen';
63
+ this.setState({ showRedBlackWarningMessage: true });
64
+ }
65
+ if (value === 'bluegreen' && this.props.isDeploymentKind) {
66
+ this.setState({ showBlueGreenDeploymentWarningMessage: true });
67
+ }
68
+ this.updateProps(key, value);
69
+ };
70
+
71
+ private updateProps(key: string, value: any) {
53
72
  const updatedConfig = cloneDeep(this.props.config);
54
73
  set(updatedConfig, key, value);
55
74
  this.props.onConfigChange(updatedConfig);
56
- };
75
+ }
57
76
 
58
77
  private fetchServices = (): void => {
59
78
  const namespace = this.props.config.options.namespace;
@@ -93,25 +112,36 @@ export class ManifestDeploymentOptions extends React.Component<
93
112
 
94
113
  public componentDidMount() {
95
114
  this.fetchServices();
115
+ this.setState({ showRedBlackWarningMessage: false });
116
+ this.setState({ showBlueGreenDeploymentWarningMessage: false });
117
+ if (this.props.config.options.strategy === 'redblack') {
118
+ this.setState({ showRedBlackWarningMessage: true });
119
+ this.updateProps('options.strategy', 'bluegreen');
120
+ }
121
+ if (this.props.config.options.strategy === 'bluegreen' && this.props.isDeploymentKind) {
122
+ this.setState({ showBlueGreenDeploymentWarningMessage: true });
123
+ }
96
124
  }
97
125
 
98
126
  public componentDidUpdate(prevProps: IManifestDeploymentOptionsProps) {
99
127
  if (prevProps.selectedAccount !== this.props.selectedAccount) {
100
- this.onConfigChange('options.namespace', null);
128
+ this.updateProps('options.namespace', null);
101
129
  }
102
130
 
103
131
  if (prevProps.config.options.namespace !== this.props.config.options.namespace) {
104
- this.onConfigChange('options.services', null);
132
+ this.updateProps('options.services', null);
105
133
  this.fetchServices();
106
134
  }
107
135
 
108
136
  if (!this.props.config.options.enableTraffic && !!this.props.config.options.strategy) {
109
- this.onConfigChange('options.enableTraffic', true);
137
+ this.updateProps('options.enableTraffic', true);
110
138
  }
111
139
  }
112
140
 
113
141
  public render() {
114
142
  const { config } = this.props;
143
+ const { showRedBlackWarningMessage } = this.state;
144
+ const { showBlueGreenDeploymentWarningMessage } = this.state;
115
145
  return (
116
146
  <>
117
147
  <h4>Rollout Strategy Options</h4>
@@ -162,6 +192,7 @@ export class ManifestDeploymentOptions extends React.Component<
162
192
  </StageConfigField>
163
193
  <StageConfigField fieldColumns={8} helpKey="kubernetes.manifest.rolloutStrategy" label="Strategy">
164
194
  <Select
195
+ id={'strategyDropdown'}
165
196
  clearable={false}
166
197
  onChange={(option: Option<IDeploymentStrategy>) => this.onConfigChange('options.strategy', option.key)}
167
198
  options={rolloutStrategies}
@@ -171,6 +202,17 @@ export class ManifestDeploymentOptions extends React.Component<
171
202
  valueKey="key"
172
203
  valueRenderer={(o) => <>{o.label}</>}
173
204
  />
205
+ {showRedBlackWarningMessage && (
206
+ <p id={'redBlackWarning'} style={{ color: 'orange' }}>
207
+ Warning: Red/black strategy is deprecated and will be removed soon. We automatically selected
208
+ blue/green instead!
209
+ </p>
210
+ )}
211
+ {showBlueGreenDeploymentWarningMessage && (
212
+ <p id={'blueGreenWarning'} style={{ color: 'orange' }}>
213
+ Warning: Blue/Green strategy may cause downtime for Deployment kind!
214
+ </p>
215
+ )}
174
216
  </StageConfigField>
175
217
  </>
176
218
  )}
@@ -36,7 +36,7 @@ export class ManifestTrafficStageConfig extends React.Component<IKubernetesManif
36
36
  selector={selector}
37
37
  modes={[SelectorMode.Static, SelectorMode.Dynamic]}
38
38
  onChange={this.onChange}
39
- includeSpinnakerKinds={['serverGroups']}
39
+ includeSpinnakerKinds={['serverGroups', 'serverGroupManagers']}
40
40
  />
41
41
  </div>
42
42
  );
@@ -0,0 +1,7 @@
1
+ import type { IDeploymentStrategy } from '@spinnaker/core';
2
+
3
+ export const strategyBlueGreen: IDeploymentStrategy = {
4
+ label: 'Blue/Green',
5
+ description: 'Disables <i>all</i> previous ReplicaSets in the cluster as soon as the new ReplicaSet is ready',
6
+ key: 'bluegreen',
7
+ };
@@ -1,5 +1,6 @@
1
+ import { strategyBlueGreen } from './bluegreen.strategy';
1
2
  import { strategyHighlander } from './highlander.strategy';
2
3
  import { strategyNone } from './none.strategy';
3
4
  import { strategyRedBlack } from './redblack.strategy';
4
5
 
5
- export const rolloutStrategies = [strategyNone, strategyRedBlack, strategyHighlander];
6
+ export const rolloutStrategies = [strategyNone, strategyRedBlack, strategyHighlander, strategyBlueGreen];
@@ -1,7 +1,7 @@
1
1
  import type { IDeploymentStrategy } from '@spinnaker/core';
2
2
 
3
3
  export const strategyRedBlack: IDeploymentStrategy = {
4
- label: 'Red/Black',
4
+ label: 'Red/Black (Deprecated)',
5
5
  description: 'Disables <i>all</i> previous ReplicaSets in the cluster as soon as the new ReplicaSet is ready',
6
6
  key: 'redblack',
7
7
  };