@spinnaker/amazon 0.12.1 → 0.12.5

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,8 @@
1
1
  import { module } from 'angular';
2
- import { defaults } from 'lodash';
3
2
 
4
3
  import type { IVpc } from '@spinnaker/core';
5
4
 
5
+ import type { IAmazonServerGroupCommand, IAmazonServerGroupDeployConfiguration } from './configure';
6
6
  import type {
7
7
  IAmazonServerGroup,
8
8
  IAmazonServerGroupView,
@@ -13,6 +13,7 @@ import type {
13
13
  IStepAdjustmentView,
14
14
  ITargetTrackingPolicy,
15
15
  } from '../domain';
16
+
16
17
  import { VpcReader } from '../vpc/VpcReader';
17
18
 
18
19
  export class AwsServerGroupTransformer {
@@ -84,31 +85,32 @@ export class AwsServerGroupTransformer {
84
85
  };
85
86
  }
86
87
 
87
- public convertServerGroupCommandToDeployConfiguration(base: any): any {
88
- // use _.defaults to avoid copying the backingData, which is huge and expensive to copy over
89
- const command = defaults({ backingData: [], viewState: [] }, base);
90
- command.cloudProvider = 'aws';
91
- command.availabilityZones = {};
92
- command.availabilityZones[command.region] = base.availabilityZones;
93
- command.loadBalancers = (base.loadBalancers || []).concat(base.vpcLoadBalancers || []);
94
- command.targetGroups = base.targetGroups || [];
95
- command.account = command.credentials;
96
- command.subnetType = command.subnetType || '';
88
+ public convertServerGroupCommandToDeployConfiguration(
89
+ base: IAmazonServerGroupCommand,
90
+ ): IAmazonServerGroupDeployConfiguration {
91
+ const deployConfig = ({ ...base } as any) as IAmazonServerGroupDeployConfiguration;
92
+
93
+ deployConfig.cloudProvider = 'aws';
94
+ deployConfig.availabilityZones = { [deployConfig.region]: base.availabilityZones };
95
+ deployConfig.loadBalancers = (base.loadBalancers || []).concat(base.vpcLoadBalancers || []);
96
+ deployConfig.targetGroups = base.targetGroups || [];
97
+ deployConfig.account = deployConfig.credentials;
98
+ deployConfig.subnetType = deployConfig.subnetType || '';
97
99
 
98
100
  if (base.viewState.mode !== 'clone') {
99
- delete command.source;
101
+ delete deployConfig.source;
100
102
  }
101
- if (!command.ramdiskId) {
102
- delete command.ramdiskId; // TODO: clean up in kato? - should ignore if empty string
103
+
104
+ if (!deployConfig.ramdiskId) {
105
+ delete deployConfig.ramdiskId; // TODO: clean up in kato? - should ignore if empty string
103
106
  }
104
- delete command.region;
105
- delete command.viewState;
106
- delete command.backingData;
107
- delete command.selectedProvider;
108
- delete command.instanceProfile;
109
- delete command.vpcId;
110
-
111
- return command;
107
+
108
+ const deleteFields = ['region', 'viewState', 'backingData', 'selectedProvider', 'instanceProfile', 'vpcId'];
109
+ deleteFields.forEach((key: keyof typeof deployConfig) => {
110
+ delete deployConfig[key];
111
+ });
112
+
113
+ return deployConfig;
112
114
  }
113
115
 
114
116
  public constructNewStepScalingPolicyTemplate(serverGroup: IAmazonServerGroup): IScalingPolicy {