Skip to content

Commit

Permalink
Merge branch 'master' into nobuObjects
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindmd committed Dec 17, 2019
2 parents 89faa7d + 932a947 commit 854c194
Show file tree
Hide file tree
Showing 104 changed files with 672 additions and 419 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ export class AmazonCertificateReader {
return CertificateReader.listCertificatesByProvider('aws').then((certificates: IAmazonCertificate[]) => {
// This account grouping should really go into clouddriver but since it's not, put it here for now.
return AccountService.listAllAccounts('aws').then(allAccountDetails => {
const accountIdToName = allAccountDetails.reduce(
(acc, accountDetails) => {
acc[accountDetails.accountId] = accountDetails.name;
return acc;
},
{} as { [id: string]: string },
);
const accountIdToName = allAccountDetails.reduce((acc, accountDetails) => {
acc[accountDetails.accountId] = accountDetails.name;
return acc;
}, {} as { [id: string]: string });

const sortedCertificates = sortBy(certificates, 'serverCertificateName');
return groupBy(sortedCertificates, cert => {
Expand Down
1 change: 0 additions & 1 deletion app/scripts/modules/amazon/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ export * from './loadBalancer';
export * from './function';
export * from './reactShims';
export * from './serverGroup';
export * from './templates';
export * from './vpc';
export * from './instance';
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { TargetGroup } from './TargetGroup';
export class AmazonLoadBalancerClusterContainer extends React.Component<ILoadBalancerClusterContainerProps> {
public shouldComponentUpdate(nextProps: ILoadBalancerClusterContainerProps) {
const serverGroupsDiffer = () =>
!isEqual((nextProps.serverGroups || []).map(g => g.name), (this.props.serverGroups || []).map(g => g.name));
!isEqual(
(nextProps.serverGroups || []).map(g => g.name),
(this.props.serverGroups || []).map(g => g.name),
);
const targetGroupsDiffer = () =>
!isEqual(
((nextProps.loadBalancer as IAmazonApplicationLoadBalancer).targetGroups || []).map(t => t.name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ export class AmazonLoadBalancersTag extends React.Component<ILoadBalancersTagPro
this.setState({ loadBalancers, isLoading: false });
}
});
AmazonLoadBalancerDataUtils.populateTargetGroups(this.props.application, this.props
.serverGroup as IAmazonServerGroup).then((targetGroups: ITargetGroup[]) => {
AmazonLoadBalancerDataUtils.populateTargetGroups(
this.props.application,
this.props.serverGroup as IAmazonServerGroup,
).then((targetGroups: ITargetGroup[]) => {
if (this.mounted) {
this.setState({ targetGroups });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ export class Listeners extends React.Component<IListenersProps, IListenersState>
className="form-control input-sm"
value={listener.externalProtocol}
onChange={event =>
this.listenerExternalProtocolChanged(listener, event.target
.value as ClassicListenerProtocol)
this.listenerExternalProtocolChanged(
listener,
event.target.value as ClassicListenerProtocol,
)
}
>
{this.protocols.map(p => (
Expand All @@ -200,8 +202,10 @@ export class Listeners extends React.Component<IListenersProps, IListenersState>
className="form-control input-sm"
value={listener.internalProtocol}
onChange={event =>
this.listenerInternalProtocolChanged(listener, event.target
.value as ClassicListenerProtocol)
this.listenerInternalProtocolChanged(
listener,
event.target.value as ClassicListenerProtocol,
)
}
>
{this.protocols.map(p => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ export class SecurityGroups extends React.Component<ISecurityGroupsProps, ISecur
}

private handleSecurityGroupsChanged = (newValues: Array<{ label: string; value: string }>): void => {
this.props.formik.setFieldValue('securityGroups', newValues.map(sg => sg.value));
this.props.formik.setFieldValue(
'securityGroups',
newValues.map(sg => sg.value),
);
};

private onRefreshStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ describe('Controller: CreateSecurityGroup', function() {
{ name: 'group2', vpcId: null, id: '2' },
{ name: 'group3', vpcId: 'vpc1-pe', id: '3' },
],
'us-west-1': [{ name: 'group1', vpcId: null, id: '1' }, { name: 'group3', vpcId: 'vpc2-pw', id: '3' }],
'us-west-1': [
{ name: 'group1', vpcId: null, id: '1' },
{ name: 'group3', vpcId: 'vpc2-pw', id: '3' },
],
},
},
test: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ module(AMAZON_SECURITYGROUP_CONFIGURE_CONFIGSECURITYGROUP_MIXIN_CONTROLLER, [
const account = getAccount();
const regions = $scope.securityGroup.regions || [];
VpcReader.listVpcs().then(function(vpcs) {
const vpcsByName = _.groupBy(vpcs.filter(vpc => vpc.account === account), 'label');
const vpcsByName = _.groupBy(
vpcs.filter(vpc => vpc.account === account),
'label',
);
$scope.allVpcs = vpcs;
const available = [];
_.forOwn(vpcsByName, function(vpcsToTest, label) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class AvailabilityZoneSelector extends React.Component<
super(props);
this.state = {
defaultZones: [],
usePreferredZones: props.usePreferredZones || (!props.selectedZones || props.selectedZones.length === 0),
usePreferredZones: props.usePreferredZones || !props.selectedZones || props.selectedZones.length === 0,
};

this.setDefaultZones(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ export class ServerGroupAdvancedSettingsCommon extends React.Component<IServerGr
multi={true}
value={values.enabledMetrics}
options={values.backingData.enabledMetrics.map(m => ({ label: m, value: m }))}
onChange={(option: Option[]) => setFieldValue('enabledMetrics', option.map(o => o.value))}
onChange={(option: Option[]) =>
setFieldValue(
'enabledMetrics',
option.map(o => o.value),
)
}
/>
</div>
</div>
Expand Down Expand Up @@ -117,7 +122,12 @@ export class ServerGroupAdvancedSettingsCommon extends React.Component<IServerGr
multi={true}
value={values.terminationPolicies}
options={values.backingData.terminationPolicies.map(m => ({ label: m, value: m }))}
onChange={(option: Option[]) => setFieldValue('terminationPolicies', option.map(o => o.value))}
onChange={(option: Option[]) =>
setFieldValue(
'terminationPolicies',
option.map(o => o.value),
)
}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,19 @@ module(AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_CHART_METRICALARMCHART_COMPONENT
this.chartData = {
loading: true,
noData: false, // flag set when server error occurs or no data available from server
threshold: [{ val: threshold, timestamp: start }, { val: threshold, timestamp: end }],
threshold: [
{ val: threshold, timestamp: start },
{ val: threshold, timestamp: end },
],
datapoints: [],
baseline: [{ val: 0, timestamp: start }, { val: 0, timestamp: end }],
topline: [{ val: topline, timestamp: start }, { val: topline, timestamp: end }],
baseline: [
{ val: 0, timestamp: start },
{ val: 0, timestamp: end },
],
topline: [
{ val: topline, timestamp: start },
{ val: topline, timestamp: end },
],
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ describe('Component: metric selector', () => {
{
namespace: 'AWS/EC2',
name: 'NetworkIn',
dimensions: [{ name: 'AutoScalingGroupName', value: 'asg-v000' }, { name: 'sr', value: '71' }],
dimensions: [
{ name: 'AutoScalingGroupName', value: 'asg-v000' },
{ name: 'sr', value: '71' },
],
},
]),
);
Expand Down Expand Up @@ -205,7 +208,10 @@ describe('Component: metric selector', () => {
{
namespace: 'AWS/EC2',
name: 'NetworkIn',
dimensions: [{ name: 'AutoScalingGroupName', value: 'asg-v000' }, { name: 'sr', value: '71' }],
dimensions: [
{ name: 'AutoScalingGroupName', value: 'asg-v000' },
{ name: 'sr', value: '71' },
],
},
{
namespace: 'AWS/EBS',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,10 @@ export class MetricSelectorController implements IController {
}

private convertDimensionsToObject(): Dictionary<string> {
return this.alarm.dimensions.reduce(
(acc: Dictionary<string>, dimension: IMetricAlarmDimension) => {
acc[dimension.name] = dimension.value;
return acc;
},
{} as Dictionary<string>,
);
return this.alarm.dimensions.reduce((acc: Dictionary<string>, dimension: IMetricAlarmDimension) => {
acc[dimension.name] = dimension.value;
return acc;
}, {} as Dictionary<string>);
}

// used to determine if dimensions have changed when selecting a metric
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ describe('Controller: modifyScalingProcesses', function() {
describe('isDirty', function() {
beforeEach(function() {
this.serverGroup = { name: 'the-asg' };
this.processes = [{ name: 'Launch', enabled: true }, { name: 'Terminate', enabled: true }];
this.processes = [
{ name: 'Launch', enabled: true },
{ name: 'Terminate', enabled: true },
];
});
it('starts as not dirty', function() {
this.initializeController(this.serverGroup, this.processes);
Expand Down
3 changes: 0 additions & 3 deletions app/scripts/modules/amazon/src/templates.ts

This file was deleted.

12 changes: 5 additions & 7 deletions app/scripts/modules/amazon/src/vpc/VpcReader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ describe('VpcReader', function() {
});

beforeEach(function() {
$http
.whenGET(API.baseUrl + '/networks/aws')
.respond(200, [
{ name: 'vpc1', id: 'vpc-1', deprecated: true },
{ name: 'vpc2', id: 'vpc-2', deprecated: false },
{ name: 'vpc3', id: 'vpc-3' },
]);
$http.whenGET(API.baseUrl + '/networks/aws').respond(200, [
{ name: 'vpc1', id: 'vpc-1', deprecated: true },
{ name: 'vpc2', id: 'vpc-2', deprecated: false },
{ name: 'vpc3', id: 'vpc-3' },
]);
});

it('adds label to vpc, including (deprecated) if deprecated field is true', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ describe('Controller: Azure.CreateSecurityGroup', function() {
{ name: 'group2', vpcId: null, id: '2' },
{ name: 'group3', vpcId: 'vpc1-pe', id: '3' },
],
'us-west-1': [{ name: 'group1', vpcId: null, id: '1' }, { name: 'group3', vpcId: 'vpc2-pw', id: '3' }],
'us-west-1': [
{ name: 'group1', vpcId: null, id: '1' },
{ name: 'group3', vpcId: 'vpc2-pw', id: '3' },
],
},
},
test: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class CfInstanceSizeFieldValidator implements IStageOrTriggerValidator {
const max: number = get(config, 'max');
const min: number = get(config, 'min');

return fieldExists && ((!hasMax || (hasMax && field <= max)) && (!hasMin || (hasMin && field >= min)));
return fieldExists && (!hasMax || (hasMax && field <= max)) && (!hasMin || (hasMin && field >= min));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ export class CloudFoundryServerGroupConfigurationSettings
<RadioButtonInput
inline={true}
value={direct ? 'direct' : 'artifact'}
options={[{ label: 'Artifact', value: 'artifact' }, { label: 'Form', value: 'direct' }]}
options={[
{ label: 'Artifact', value: 'artifact' },
{ label: 'Form', value: 'direct' },
]}
onChange={(e: any) => this.manifestSourceUpdated(e.target.value)}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spinnaker/core",
"version": "0.0.435",
"version": "0.0.436",
"main": "lib/lib.js",
"typings": "lib/index.d.ts",
"scripts": {
Expand Down
21 changes: 10 additions & 11 deletions app/scripts/modules/core/src/account/AccountService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ describe('Service: AccountService', () => {
afterEach(SETTINGS.resetToOriginal);

it('should filter the list of accounts by provider when supplied', done => {
$http
.expectGET(`${API.baseUrl}/credentials?expand=true`)
.respond(200, [
{ name: 'test', type: 'aws' },
{ name: 'prod', type: 'aws' },
{ name: 'prod', type: 'gce' },
{ name: 'gce-test', type: 'gce' },
]);
$http.expectGET(`${API.baseUrl}/credentials?expand=true`).respond(200, [
{ name: 'test', type: 'aws' },
{ name: 'prod', type: 'aws' },
{ name: 'prod', type: 'gce' },
{ name: 'gce-test', type: 'gce' },
]);

AccountService.listAccounts('aws').then((accounts: IAccount[]) => {
expect(accounts.length).toBe(2);
Expand All @@ -40,9 +38,10 @@ describe('Service: AccountService', () => {

describe('getAllAccountDetailsForProvider', () => {
it('should return details for each account', done => {
$http
.expectGET(API.baseUrl + '/credentials?expand=true')
.respond(200, [{ name: 'test', type: 'aws' }, { name: 'prod', type: 'aws' }]);
$http.expectGET(API.baseUrl + '/credentials?expand=true').respond(200, [
{ name: 'test', type: 'aws' },
{ name: 'prod', type: 'aws' },
]);

AccountService.getAllAccountDetailsForProvider('aws').then((details: any) => {
expect(details.length).toBe(2);
Expand Down
9 changes: 3 additions & 6 deletions app/scripts/modules/core/src/account/AccountService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,9 @@ export class AccountService {

public static applicationAccounts(application: Application = null): IPromise<IAccountDetails[]> {
return $q.all([this.listProviders(application), this.listAccounts()]).then(([providers, accounts]) => {
return providers.reduce(
(memo, p) => {
return memo.concat(accounts.filter(acc => acc.cloudProvider === p));
},
[] as IAccountDetails[],
);
return providers.reduce((memo, p) => {
return memo.concat(accounts.filter(acc => acc.cloudProvider === p));
}, [] as IAccountDetails[]);
});
}

Expand Down
15 changes: 12 additions & 3 deletions app/scripts/modules/core/src/api/ApiService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ describe('API Service', function() {
let succeeded = false;
API.one('fine')
.get()
.then(() => (succeeded = true), () => (rejected = true));
.then(
() => (succeeded = true),
() => (rejected = true),
);

$httpBackend.flush();
expect((AuthenticationInitializer.reauthenticateUser as Spy).calls.count()).toBe(0);
Expand All @@ -110,7 +113,10 @@ describe('API Service', function() {
$httpBackend.expectGET(`${baseUrl}/some-array`).respond(200, []);
API.one('some-array')
.get()
.then(() => (succeeded = true), () => (rejected = true));
.then(
() => (succeeded = true),
() => (rejected = true),
);
$httpBackend.flush();

expect((AuthenticationInitializer.reauthenticateUser as Spy).calls.count()).toBe(0);
Expand All @@ -123,7 +129,10 @@ describe('API Service', function() {
$httpBackend.expectGET(`${baseUrl}/some-object`).respond(200, {});
API.one('some-object')
.get()
.then(() => (succeeded = true), () => (rejected = true));
.then(
() => (succeeded = true),
() => (rejected = true),
);
$httpBackend.flush();

expect((AuthenticationInitializer.reauthenticateUser as Spy).calls.count()).toBe(0);
Expand Down
Loading

0 comments on commit 854c194

Please sign in to comment.