@spinnaker/kubernetes 0.3.2 → 0.5.2

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.
@@ -19,10 +19,12 @@ export interface IManifestDeploymentOptionsProps {
19
19
  }
20
20
  export interface IManifestDeploymentOptionsState {
21
21
  services: string[];
22
+ showRedBlackWarningMessage: boolean;
22
23
  }
23
24
  export declare class ManifestDeploymentOptions extends React.Component<IManifestDeploymentOptionsProps, IManifestDeploymentOptionsState> {
24
25
  state: IManifestDeploymentOptionsState;
25
26
  private onConfigChange;
27
+ private updateProps;
26
28
  private fetchServices;
27
29
  private getServiceOptions;
28
30
  private strategyOptionRenderer;
@@ -1,4 +1,5 @@
1
1
  export * from './deleteManifest/deleteManifestStage';
2
2
  export * from './deployManifest/deployManifestStage';
3
3
  export * from './patchManifest/patchManifestStage';
4
+ export * from './rolloutRestartManifest/rolloutRestartManifestStage';
4
5
  export * from './runJob/runJobStage';
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { Application, IStage, IStageConfigProps } from '@spinnaker/core';
3
+ import type { IManifestSelector } from '../../../manifest/selector/IManifestSelector';
4
+ export interface IKubernetesManifestStageConfigProps extends IStageConfigProps {
5
+ application: Application;
6
+ stage: IManifestSelector & IStage;
7
+ stageFieldUpdated: () => void;
8
+ }
9
+ export declare class RolloutRestartManifestStageConfig extends React.Component<IKubernetesManifestStageConfigProps> {
10
+ componentDidMount: () => void;
11
+ private onChange;
12
+ render(): JSX.Element;
13
+ }
@@ -0,0 +1,4 @@
1
+ import { DeployStatus } from '../deployManifest/manifestStatus/DeployStatus';
2
+ export declare class RolloutRestartStatus extends DeployStatus {
3
+ static title: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ import type { IDeploymentStrategy } from '@spinnaker/core';
2
+ export declare const strategyBlueGreen: IDeploymentStrategy;
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@spinnaker/kubernetes",
3
3
  "license": "Apache-2.0",
4
- "version": "0.3.2",
4
+ "version": "0.5.2",
5
5
  "module": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
7
10
  "scripts": {
8
11
  "clean": "shx rm -rf dist",
9
12
  "prepublishOnly": "npm run build",
@@ -13,7 +16,7 @@
13
16
  "lib": "npm run build"
14
17
  },
15
18
  "dependencies": {
16
- "@spinnaker/core": "^0.22.2",
19
+ "@spinnaker/core": "^0.27.0",
17
20
  "@uirouter/angularjs": "1.0.26",
18
21
  "@uirouter/react": "1.0.7",
19
22
  "angular": "1.6.10",
@@ -35,8 +38,8 @@
35
38
  "rxjs": "6.6.7"
36
39
  },
37
40
  "devDependencies": {
38
- "@spinnaker/eslint-plugin": "^3.0.1",
39
- "@spinnaker/scripts": "^0.3.0",
41
+ "@spinnaker/eslint-plugin": "^3.0.2",
42
+ "@spinnaker/scripts": "^0.3.1",
40
43
  "@types/angular": "1.6.26",
41
44
  "@types/angular-ui-bootstrap": "0.13.41",
42
45
  "@types/dompurify": "^2.3.3",
@@ -50,5 +53,5 @@
50
53
  "shx": "0.3.3",
51
54
  "typescript": "4.3.5"
52
55
  },
53
- "gitHead": "587b5a7a5fe2121cd93bed86e5e83795ee401be0"
56
+ "gitHead": "217b75396c5ec25d9b2019a849593b0b8d52e916"
54
57
  }
@@ -49,5 +49,27 @@ describe('<ManifestDeploymentOptions />', () => {
49
49
  wrapper = shallow(<ManifestDeploymentOptions {...props} />);
50
50
  expect(wrapper.find('input[type="checkbox"]').at(1).props().disabled).toEqual(true);
51
51
  });
52
+ it('disables the traffic checkbox when blue/green rollout strategy is selected', () => {
53
+ props.config.options.strategy = 'bluegreen';
54
+ wrapper = shallow(<ManifestDeploymentOptions {...props} />);
55
+ expect(wrapper.find('input[type="checkbox"]').at(1).props().disabled).toEqual(true);
56
+ });
57
+
58
+ it('strategy bluegreen should not display warning label', () => {
59
+ props.config.options.strategy = 'bluegreen';
60
+ wrapper = shallow(<ManifestDeploymentOptions {...props} />);
61
+ expect(wrapper.find('p[id="redBlackWarning"]').exists()).toEqual(false);
62
+ });
63
+ it('strategy highlander should not display warning label', () => {
64
+ props.config.options.strategy = 'highlander';
65
+ wrapper = shallow(<ManifestDeploymentOptions {...props} />);
66
+ expect(wrapper.find('p[id="redBlackWarning"]').exists()).toEqual(false);
67
+ });
68
+
69
+ it('strategy redblack should display warning label', () => {
70
+ props.config.options.strategy = 'redblack';
71
+ wrapper = shallow(<ManifestDeploymentOptions {...props} />);
72
+ expect(wrapper.find('p[id="redBlackWarning"]').exists()).toEqual(true);
73
+ });
52
74
  });
53
75
  });
@@ -41,19 +41,29 @@ export interface IManifestDeploymentOptionsProps {
41
41
 
42
42
  export interface IManifestDeploymentOptionsState {
43
43
  services: string[];
44
+ showRedBlackWarningMessage: boolean;
44
45
  }
45
46
 
46
47
  export class ManifestDeploymentOptions extends React.Component<
47
48
  IManifestDeploymentOptionsProps,
48
49
  IManifestDeploymentOptionsState
49
50
  > {
50
- public state: IManifestDeploymentOptionsState = { services: [] };
51
+ public state: IManifestDeploymentOptionsState = { services: [], showRedBlackWarningMessage: false };
51
52
 
52
53
  private onConfigChange = (key: string, value: any): void => {
54
+ this.setState({ showRedBlackWarningMessage: false });
55
+ if (value === 'redblack') {
56
+ value = 'bluegreen';
57
+ this.setState({ showRedBlackWarningMessage: true });
58
+ }
59
+ this.updateProps(key, value);
60
+ };
61
+
62
+ private updateProps(key: string, value: any) {
53
63
  const updatedConfig = cloneDeep(this.props.config);
54
64
  set(updatedConfig, key, value);
55
65
  this.props.onConfigChange(updatedConfig);
56
- };
66
+ }
57
67
 
58
68
  private fetchServices = (): void => {
59
69
  const namespace = this.props.config.options.namespace;
@@ -93,25 +103,31 @@ export class ManifestDeploymentOptions extends React.Component<
93
103
 
94
104
  public componentDidMount() {
95
105
  this.fetchServices();
106
+ this.setState({ showRedBlackWarningMessage: false });
107
+ if (this.props.config.options.strategy === 'redblack') {
108
+ this.setState({ showRedBlackWarningMessage: true });
109
+ this.updateProps('options.strategy', 'bluegreen');
110
+ }
96
111
  }
97
112
 
98
113
  public componentDidUpdate(prevProps: IManifestDeploymentOptionsProps) {
99
114
  if (prevProps.selectedAccount !== this.props.selectedAccount) {
100
- this.onConfigChange('options.namespace', null);
115
+ this.updateProps('options.namespace', null);
101
116
  }
102
117
 
103
118
  if (prevProps.config.options.namespace !== this.props.config.options.namespace) {
104
- this.onConfigChange('options.services', null);
119
+ this.updateProps('options.services', null);
105
120
  this.fetchServices();
106
121
  }
107
122
 
108
123
  if (!this.props.config.options.enableTraffic && !!this.props.config.options.strategy) {
109
- this.onConfigChange('options.enableTraffic', true);
124
+ this.updateProps('options.enableTraffic', true);
110
125
  }
111
126
  }
112
127
 
113
128
  public render() {
114
129
  const { config } = this.props;
130
+ const { showRedBlackWarningMessage } = this.state;
115
131
  return (
116
132
  <>
117
133
  <h4>Rollout Strategy Options</h4>
@@ -162,6 +178,7 @@ export class ManifestDeploymentOptions extends React.Component<
162
178
  </StageConfigField>
163
179
  <StageConfigField fieldColumns={8} helpKey="kubernetes.manifest.rolloutStrategy" label="Strategy">
164
180
  <Select
181
+ id={'strategyDropdown'}
165
182
  clearable={false}
166
183
  onChange={(option: Option<IDeploymentStrategy>) => this.onConfigChange('options.strategy', option.key)}
167
184
  options={rolloutStrategies}
@@ -171,6 +188,12 @@ export class ManifestDeploymentOptions extends React.Component<
171
188
  valueKey="key"
172
189
  valueRenderer={(o) => <>{o.label}</>}
173
190
  />
191
+ {showRedBlackWarningMessage && (
192
+ <p id={'redBlackWarning'} style={{ color: 'orange' }}>
193
+ Warning: Red/black strategy is deprecated and will be removed soon. We automatically selected
194
+ blue/green instead!
195
+ </p>
196
+ )}
174
197
  </StageConfigField>
175
198
  </>
176
199
  )}
@@ -1,4 +1,5 @@
1
1
  export * from './deleteManifest/deleteManifestStage';
2
2
  export * from './deployManifest/deployManifestStage';
3
3
  export * from './patchManifest/patchManifestStage';
4
+ export * from './rolloutRestartManifest/rolloutRestartManifestStage';
4
5
  export * from './runJob/runJobStage';
@@ -0,0 +1,46 @@
1
+ import { defaults } from 'lodash';
2
+ import React from 'react';
3
+
4
+ import type { Application, IStage, IStageConfigProps } from '@spinnaker/core';
5
+
6
+ import type { IManifestSelector } from '../../../manifest/selector/IManifestSelector';
7
+ import { SelectorMode } from '../../../manifest/selector/IManifestSelector';
8
+ import { ManifestSelector } from '../../../manifest/selector/ManifestSelector';
9
+
10
+ export interface IKubernetesManifestStageConfigProps extends IStageConfigProps {
11
+ application: Application;
12
+ stage: IManifestSelector & IStage;
13
+ stageFieldUpdated: () => void;
14
+ }
15
+
16
+ export class RolloutRestartManifestStageConfig extends React.Component<IKubernetesManifestStageConfigProps> {
17
+ public componentDidMount = (): void => {
18
+ defaults(this.props.stage, {
19
+ app: this.props.application.name,
20
+ cloudProvider: 'kubernetes',
21
+ });
22
+ this.props.stageFieldUpdated();
23
+ };
24
+
25
+ private onChange = (stage: IManifestSelector): void => {
26
+ Object.assign(this.props.stage, stage);
27
+ this.props.stageFieldUpdated();
28
+ };
29
+
30
+ public render() {
31
+ const selector = { ...this.props.stage };
32
+ return (
33
+ <div className="form-horizontal">
34
+ <h4>Manifest</h4>
35
+ <div className="horizontal-rule" />
36
+ <ManifestSelector
37
+ application={this.props.application}
38
+ selector={selector}
39
+ modes={[SelectorMode.Static, SelectorMode.Dynamic, SelectorMode.Label]}
40
+ onChange={this.onChange}
41
+ includeSpinnakerKinds={null}
42
+ />
43
+ </div>
44
+ );
45
+ }
46
+ }
@@ -0,0 +1,20 @@
1
+ import { ExecutionDetailsTasks, Registry } from '@spinnaker/core';
2
+
3
+ import { RolloutRestartManifestStageConfig } from './RolloutRestartManifestStageConfig';
4
+ import { DeployStatus } from '../deployManifest/manifestStatus/DeployStatus';
5
+ import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';
6
+
7
+ export class RolloutRestartStatus extends DeployStatus {
8
+ public static title = 'RolloutRestartStatus';
9
+ }
10
+
11
+ const STAGE_NAME = 'Rollout Restart (Manifest)';
12
+ Registry.pipeline.registerStage({
13
+ label: STAGE_NAME,
14
+ description: 'Perform a rolling restart of a manifest.',
15
+ key: 'rollingRestartManifest',
16
+ cloudProvider: 'kubernetes',
17
+ component: RolloutRestartManifestStageConfig,
18
+ executionDetailsSections: [RolloutRestartStatus, ExecutionDetailsTasks],
19
+ validators: manifestSelectorValidators(STAGE_NAME),
20
+ });
@@ -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
  };