@spinnaker/google 0.0.76 → 0.1.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.
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
+ import './customInstanceConfigurer.component.less';
2
3
  export interface ICustomInstanceConfig {
3
4
  vCpuCount: number;
4
5
  memory: number;
5
6
  instanceFamily: string;
7
+ extendedMemory: boolean;
6
8
  }
7
9
  export interface ICustomInstanceConfigurerProps {
8
10
  vCpuList: number[];
@@ -11,6 +13,7 @@ export interface ICustomInstanceConfigurerProps {
11
13
  selectedVCpuCount: number;
12
14
  selectedMemory: number;
13
15
  selectedInstanceFamily: string;
16
+ selectedExtendedMemory: boolean;
14
17
  onChange: (config: ICustomInstanceConfig) => void;
15
18
  }
16
19
  export declare class CustomInstanceConfigurer extends React.Component<ICustomInstanceConfigurerProps> {
@@ -18,4 +21,6 @@ export declare class CustomInstanceConfigurer extends React.Component<ICustomIns
18
21
  private handleVCpuChange;
19
22
  private handleMemoryChange;
20
23
  private handleInstanceFamilyChange;
24
+ private handleMemoryChangeCustom;
25
+ private handleExtendedMemory;
21
26
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spinnaker/google",
3
3
  "license": "Apache-2.0",
4
- "version": "0.0.76",
4
+ "version": "0.1.2",
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.14.1",
16
+ "@spinnaker/core": "^0.16.0",
17
17
  "@uirouter/angularjs": "1.0.26",
18
18
  "angular": "1.6.10",
19
19
  "angular-ui-bootstrap": "2.5.0",
@@ -26,8 +26,8 @@
26
26
  "ui-select": "0.19.8"
27
27
  },
28
28
  "devDependencies": {
29
- "@spinnaker/eslint-plugin": "^3.0.0",
30
- "@spinnaker/scripts": "^0.2.2",
29
+ "@spinnaker/eslint-plugin": "^3.0.1",
30
+ "@spinnaker/scripts": "^0.2.4",
31
31
  "@types/angular": "1.6.26",
32
32
  "@types/angular-mocks": "1.5.10",
33
33
  "@types/angular-ui-bootstrap": "0.13.41",
@@ -37,5 +37,5 @@
37
37
  "shx": "0.3.3",
38
38
  "typescript": "4.3.5"
39
39
  },
40
- "gitHead": "b36e5fa30e23cd60007e6839b0dab5e41bd410d5"
40
+ "gitHead": "59026ea6af7b81ffb8e8c59e18f43396906ddafb"
41
41
  }
@@ -1,5 +1,6 @@
1
- import { IGceHealthCheck, IGceHealthCheckKind } from '../domain';
2
- import { parseHealthCheckUrl, getHealthCheckOptions, getDuplicateHealthCheckNames } from './healthCheckUtils';
1
+ import type { IGceHealthCheck } from '../domain';
2
+ import { IGceHealthCheckKind } from '../domain';
3
+ import { getDuplicateHealthCheckNames, getHealthCheckOptions, parseHealthCheckUrl } from './healthCheckUtils';
3
4
 
4
5
  describe('Health check display utils', () => {
5
6
  let healthChecks: IGceHealthCheck[];
@@ -30,7 +30,9 @@ const helpContents: { [key: string]: string } = {
30
30
  'gce.instance.customInstance.cores':
31
31
  '<ul><li>Above 1, vCPU count must be even.</li><li>Zones that support Haswell and Ivy Bridge processors can support custom machine types up to 32 vCPUs.</li><li>Zones that support Sandy Bridge processors can support up to 16 vCPUs.</li></ul>',
32
32
  'gce.instance.customInstance.memory':
33
- '<ul><li>Memory per vCPU must be between .9 GB and 6.5 GB.</li><li>Total memory must be a multiple of 256 MB.</li></ul>',
33
+ '<ul><li>Memory per vCPU must be between .9 GB and 6.5 GB.</li><li>Total memory must be a multiple of 256 MB.</li><li>Memory per vCPU must be between .9 GB and 800 GB if selected extended memory feature.</li></ul>',
34
+ 'gce.instance.customInstance.extendedmemory':
35
+ 'Add more memory per vCPU to your VM instance. <a href="https://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type#extendedmemory">Click here </a>for more information regarding extended memory',
34
36
  'gce.instance.customMetadata.instance-template': 'The instance template used to configure this instance.',
35
37
  'gce.instance.customMetadata.load-balancer-names':
36
38
  'This field is used to "remember" what load balancers this instance is associated with, even if it is deregistered.',
@@ -88,9 +88,9 @@ module(GOOGLE_INSTANCE_CUSTOM_CUSTOMINSTANCEBUILDER_GCE_SERVICE, []).factory(
88
88
  return [..._.range(min, max, 0.25), max];
89
89
  }
90
90
 
91
- function memoryIsValid(instanceFamily, totalMemory, vCpuCount) {
91
+ function memoryIsValid(instanceFamily, totalMemory, vCpuCount, extendedMemory) {
92
92
  const min = minMemoryForVCpuCount(instanceFamily, vCpuCount);
93
- const max = maxMemoryForVCpuCount(instanceFamily, vCpuCount);
93
+ const max = extendedMemory ? 800 : maxMemoryForVCpuCount(instanceFamily, vCpuCount);
94
94
  return _.inRange(totalMemory, min, max) || totalMemory === max;
95
95
  }
96
96
 
@@ -98,13 +98,14 @@ module(GOOGLE_INSTANCE_CUSTOM_CUSTOMINSTANCEBUILDER_GCE_SERVICE, []).factory(
98
98
  * In the API, you must always provide memory in MB units.
99
99
  * Format: custom-NUMBER_OF_CPUS-AMOUNT_OF_MEMORY
100
100
  * */
101
- function generateInstanceTypeString(instanceFamily, vCpuCount, totalMemory) {
101
+ function generateInstanceTypeString(instanceFamily, vCpuCount, totalMemory, extendedMemory) {
102
+ const extendedFlag = extendedMemory ? '-ext' : '';
102
103
  const memoryInMbs = Number(totalMemory) * 1024;
103
104
  instanceFamily = instanceFamily.toLowerCase();
104
105
  if (instanceFamily === 'n1') {
105
- return `custom-${vCpuCount}-${memoryInMbs}`;
106
+ return `custom-${vCpuCount}-${memoryInMbs}${extendedFlag}`;
106
107
  }
107
- return `${instanceFamily}-custom-${vCpuCount}-${memoryInMbs}`;
108
+ return `${instanceFamily}-custom-${vCpuCount}-${memoryInMbs}${extendedFlag}`;
108
109
  }
109
110
 
110
111
  function parseInstanceTypeString(instanceTypeString) {
@@ -129,10 +130,11 @@ module(GOOGLE_INSTANCE_CUSTOM_CUSTOMINSTANCEBUILDER_GCE_SERVICE, []).factory(
129
130
  totalMemory,
130
131
  location,
131
132
  locationToInstanceTypesMap,
133
+ extendedMemory,
132
134
  ) {
133
135
  return _.every([
134
136
  numberOfVCpusIsValid(instanceFamily, vCpuCount),
135
- memoryIsValid(instanceFamily, totalMemory, vCpuCount),
137
+ memoryIsValid(instanceFamily, totalMemory, vCpuCount, extendedMemory),
136
138
  vCpuCountForLocationIsValid(instanceFamily, vCpuCount, location, locationToInstanceTypesMap),
137
139
  ]);
138
140
  }
@@ -1,5 +1,6 @@
1
1
  import { mock } from 'angular';
2
- import { GCE_SECURITY_GROUP_HELP_TEXT_SERVICE, GceSecurityGroupHelpTextService } from './securityGroupHelpText.service';
2
+ import type { GceSecurityGroupHelpTextService } from './securityGroupHelpText.service';
3
+ import { GCE_SECURITY_GROUP_HELP_TEXT_SERVICE } from './securityGroupHelpText.service';
3
4
 
4
5
  describe('Service: gceSecurityGroupHelpTextService', () => {
5
6
  let $q: ng.IQService;
@@ -254,6 +254,7 @@ angular
254
254
  let vCpuCount = _.get(c, 'viewState.customInstance.vCpuCount');
255
255
  const instanceFamily = _.get(c, 'viewState.customInstance.instanceFamily');
256
256
  const memory = _.get(c, 'viewState.customInstance.memory');
257
+ const extendedMemory = _.get(c, 'viewState.customInstance.extendedMemory');
257
258
  const { zone, regional, region } = c;
258
259
  const { locationToInstanceTypesMap } = c.backingData.credentialsKeyedByAccount[c.credentials];
259
260
  const location = regional ? region : zone;
@@ -294,7 +295,7 @@ angular
294
295
  _.every([
295
296
  memory,
296
297
  vCpuCount,
297
- !gceCustomInstanceBuilderService.memoryIsValid(instanceFamily, memory, vCpuCount),
298
+ !gceCustomInstanceBuilderService.memoryIsValid(instanceFamily, memory, vCpuCount, extendedMemory),
298
299
  ])
299
300
  ) {
300
301
  _.set(c, 'viewState.customInstance.memory', undefined);
@@ -1,4 +1,5 @@
1
- import { GceAcceleratorService, IGceAcceleratorCommand, IGceAcceleratorTypeRaw } from './gceAccelerator.service';
1
+ import type { IGceAcceleratorCommand, IGceAcceleratorTypeRaw } from './gceAccelerator.service';
2
+ import { GceAcceleratorService } from './gceAccelerator.service';
2
3
 
3
4
  describe('GceAcceleratorService', () => {
4
5
  const acceleratorA: IGceAcceleratorTypeRaw = {
@@ -216,7 +216,7 @@ angular
216
216
  const c = $scope.command;
217
217
  const location = c.regional ? c.region : c.zone;
218
218
  const { locationToInstanceTypesMap } = c.backingData.credentialsKeyedByAccount[c.credentials];
219
-
219
+ const extendedMemory = _.get(c, 'viewState.customInstance.extendedMemory');
220
220
  const customInstanceChoices = [
221
221
  _.get(c, 'viewState.customInstance.instanceFamily'),
222
222
  _.get(c, 'viewState.customInstance.vCpuCount'),
@@ -230,10 +230,14 @@ angular
230
230
  ...customInstanceChoices,
231
231
  location,
232
232
  locationToInstanceTypesMap,
233
+ extendedMemory,
233
234
  ),
234
235
  ])
235
236
  ) {
236
- c.instanceType = gceCustomInstanceBuilderService.generateInstanceTypeString(...customInstanceChoices);
237
+ c.instanceType = gceCustomInstanceBuilderService.generateInstanceTypeString(
238
+ ...customInstanceChoices,
239
+ extendedMemory,
240
+ );
237
241
 
238
242
  instanceTypeService.getInstanceTypeDetails(c.selectedProvider, 'buildCustom').then((instanceTypeDetails) => {
239
243
  c.viewState.instanceTypeDetails = instanceTypeDetails;
@@ -2,12 +2,14 @@ import React from 'react';
2
2
  import type { Option } from 'react-select';
3
3
  import Select from 'react-select';
4
4
 
5
- import { HelpField } from '@spinnaker/core';
5
+ import { CheckboxInput, HelpField } from '@spinnaker/core';
6
+ import './customInstanceConfigurer.component.less';
6
7
 
7
8
  export interface ICustomInstanceConfig {
8
9
  vCpuCount: number;
9
10
  memory: number;
10
11
  instanceFamily: string;
12
+ extendedMemory: boolean;
11
13
  }
12
14
 
13
15
  export interface ICustomInstanceConfigurerProps {
@@ -17,6 +19,7 @@ export interface ICustomInstanceConfigurerProps {
17
19
  selectedVCpuCount: number;
18
20
  selectedMemory: number;
19
21
  selectedInstanceFamily: string;
22
+ selectedExtendedMemory: boolean;
20
23
  onChange: (config: ICustomInstanceConfig) => void;
21
24
  }
22
25
 
@@ -50,7 +53,7 @@ export class CustomInstanceConfigurer extends React.Component<ICustomInstanceCon
50
53
  />
51
54
  </div>
52
55
  </div>
53
- <div className="row">
56
+ <div className="row gce-instance-build-custom-select">
54
57
  <div className="col-md-5 sm-label-right">
55
58
  <b>Cores </b>
56
59
  <HelpField id="gce.instance.customInstance.cores" />
@@ -64,20 +67,50 @@ export class CustomInstanceConfigurer extends React.Component<ICustomInstanceCon
64
67
  />
65
68
  </div>
66
69
  </div>
67
- <div className="row" style={{ marginTop: '5px' }}>
70
+ <div className="row gce-instance-build-custom-select">
68
71
  <div className="col-md-5 sm-label-right">
69
72
  <b>Memory (Gb) </b>
70
73
  <HelpField id="gce.instance.customInstance.memory" />
71
74
  </div>
72
75
  <div className="col-md-3">
73
- <Select
74
- options={memoryOptions}
75
- clearable={false}
76
- value={{ label: selectedMemoryLabel, value: this.props.selectedMemory }}
77
- onChange={this.handleMemoryChange}
78
- />
76
+ {this.props.selectedExtendedMemory ? (
77
+ <input
78
+ type="number"
79
+ name="memory"
80
+ className="form-control"
81
+ value={this.props.selectedMemory}
82
+ onChange={(event) => this.handleMemoryChangeCustom(event.target.value)}
83
+ />
84
+ ) : (
85
+ <Select
86
+ options={memoryOptions}
87
+ clearable={false}
88
+ value={{ label: selectedMemoryLabel, value: this.props.selectedMemory }}
89
+ onChange={this.handleMemoryChange}
90
+ />
91
+ )}
79
92
  </div>
80
93
  </div>
94
+ {this.props.selectedInstanceFamily !== 'E2' ? (
95
+ <div className="row gce-instance-build-custom-select">
96
+ <div className="col-md-5 sm-label-right"></div>
97
+ <div className="col-md-3">
98
+ <span className="gce-instance-build-custom-extended-memory-checkbox">
99
+ <CheckboxInput
100
+ name="extendedMemory"
101
+ text="Extended Memory"
102
+ checked={this.props.selectedExtendedMemory}
103
+ onChange={(event: { target: { checked: boolean } }) => {
104
+ this.handleExtendedMemory(event.target.checked);
105
+ }}
106
+ />
107
+ <div className="gce-instance-build-custom-extended-memory-checkbox-helptext">
108
+ <HelpField id="gce.instance.customInstance.extendedmemory" />
109
+ </div>
110
+ </span>
111
+ </div>
112
+ </div>
113
+ ) : null}
81
114
  </div>
82
115
  );
83
116
  }
@@ -88,6 +121,7 @@ export class CustomInstanceConfigurer extends React.Component<ICustomInstanceCon
88
121
  instanceFamily: this.props.selectedInstanceFamily,
89
122
  vCpuCount: value,
90
123
  memory: this.props.selectedMemory,
124
+ extendedMemory: this.props.selectedExtendedMemory,
91
125
  });
92
126
  };
93
127
 
@@ -97,6 +131,7 @@ export class CustomInstanceConfigurer extends React.Component<ICustomInstanceCon
97
131
  instanceFamily: this.props.selectedInstanceFamily,
98
132
  vCpuCount: this.props.selectedVCpuCount,
99
133
  memory: value,
134
+ extendedMemory: this.props.selectedExtendedMemory,
100
135
  });
101
136
  };
102
137
 
@@ -106,6 +141,26 @@ export class CustomInstanceConfigurer extends React.Component<ICustomInstanceCon
106
141
  instanceFamily: value,
107
142
  vCpuCount: this.props.selectedVCpuCount,
108
143
  memory: this.props.selectedMemory,
144
+ extendedMemory: value === 'E2' ? false : this.props.selectedExtendedMemory,
145
+ });
146
+ };
147
+
148
+ private handleMemoryChangeCustom = (val: string) => {
149
+ const value = +val;
150
+ this.props.onChange({
151
+ instanceFamily: this.props.selectedInstanceFamily,
152
+ vCpuCount: this.props.selectedVCpuCount,
153
+ memory: value,
154
+ extendedMemory: this.props.selectedExtendedMemory,
155
+ });
156
+ };
157
+
158
+ private handleExtendedMemory = (checked: boolean) => {
159
+ this.props.onChange({
160
+ instanceFamily: this.props.selectedInstanceFamily,
161
+ vCpuCount: this.props.selectedVCpuCount,
162
+ memory: this.props.selectedMemory,
163
+ extendedMemory: checked,
109
164
  });
110
165
  };
111
166
  }
@@ -7,6 +7,7 @@
7
7
  selected-v-cpu-count="instanceArchetypeCtrl.command.viewState.customInstance.vCpuCount"
8
8
  memory-list="instanceArchetypeCtrl.command.backingData.customInstanceTypes.memoryList"
9
9
  selected-memory="instanceArchetypeCtrl.command.viewState.customInstance.memory"
10
+ selected-extended-memory="instanceArchetypeCtrl.command.viewState.customInstance.extendedMemory"
10
11
  on-change="instanceArchetypeCtrl.command.setCustomInstanceViewState"
11
12
  ></gce-custom-instance-configurer>
12
13
  </div>
@@ -0,0 +1,9 @@
1
+ .gce-instance-build-custom-select {
2
+ margin-top: 5px;
3
+ .gce-instance-build-custom-extended-memory-checkbox {
4
+ display: flex;
5
+ }
6
+ .gce-instance-build-custom-extended-memory-checkbox-helptext {
7
+ margin: 8px 0px 0px 3px;
8
+ }
9
+ }
@@ -15,6 +15,7 @@ module(GCE_CUSTOM_INSTANCE_CONFIGURER, []).component(
15
15
  'selectedVCpuCount',
16
16
  'selectedMemory',
17
17
  'selectedInstanceFamily',
18
+ 'selectedExtendedMemory',
18
19
  'onChange',
19
20
  ]),
20
21
  );