Skip to content

Commit

Permalink
refactor(*): Consistent bracket spacing (spinnaker#4307)
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Reynolds authored Oct 23, 2017
1 parent 9dcc554 commit 484c91a
Show file tree
Hide file tree
Showing 311 changed files with 1,459 additions and 1,430 deletions.
4 changes: 2 additions & 2 deletions app/scripts/modules/amazon/src/help/amazon.help.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {module} from 'angular';
import {HELP_CONTENTS_REGISTRY, HelpContentsRegistry} from '@spinnaker/core';
import { module } from 'angular';
import { HELP_CONTENTS_REGISTRY, HelpContentsRegistry } from '@spinnaker/core';

const helpContents: {[key: string]: string} = {
'aws.associateElasticIp.elasticIp':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,30 @@ export class AmazonLoadBalancersTag extends React.Component<ILoadBalancersTagPro
targetGroups: [],
};

LoadBalancerDataUtils.populateLoadBalancers(props.application, props.serverGroup).then((loadBalancers) => this.setState({loadBalancers}))
AmazonLoadBalancerDataUtils.populateTargetGroups(props.application, props.serverGroup as IAmazonServerGroup).then((targetGroups: ITargetGroup[]) => this.setState({targetGroups}))
LoadBalancerDataUtils.populateLoadBalancers(props.application, props.serverGroup).then((loadBalancers) => this.setState({ loadBalancers }))
AmazonLoadBalancerDataUtils.populateTargetGroups(props.application, props.serverGroup as IAmazonServerGroup).then((targetGroups: ITargetGroup[]) => this.setState({ targetGroups }))

this.loadBalancersRefreshUnsubscribe = props.application.getDataSource('loadBalancers').onRefresh(null, () => { this.forceUpdate(); });
}

private showLoadBalancerDetails(loadBalancer: ILoadBalancer): void {
const { $state } = ReactInjector;
const serverGroup = this.props.serverGroup;
ReactGA.event({category: 'Cluster Pod', action: `Load Load Balancer Details (multiple menu)`});
ReactGA.event({ category: 'Cluster Pod', action: `Load Load Balancer Details (multiple menu)` });
const nextState = $state.current.name.endsWith('.clusters') ? '.loadBalancerDetails' : '^.loadBalancerDetails';
$state.go(nextState, {region: serverGroup.region, accountId: serverGroup.account, name: loadBalancer.name, provider: serverGroup.type});
$state.go(nextState, { region: serverGroup.region, accountId: serverGroup.account, name: loadBalancer.name, provider: serverGroup.type });
}

private showTargetGroupDetails(targetGroup: ITargetGroup): void {
const { $state } = ReactInjector;
const serverGroup = this.props.serverGroup;
ReactGA.event({category: 'Cluster Pod', action: `Load Target Group Details (multiple menu)`});
ReactGA.event({ category: 'Cluster Pod', action: `Load Target Group Details (multiple menu)` });
const nextState = $state.current.name.endsWith('.clusters') ? '.targetGroupDetails' : '^.targetGroupDetails';
$state.go(nextState, {region: serverGroup.region, accountId: serverGroup.account, name: targetGroup.name, provider: serverGroup.type, loadBalancerName: targetGroup.loadBalancerNames[0]});
$state.go(nextState, { region: serverGroup.region, accountId: serverGroup.account, name: targetGroup.name, provider: serverGroup.type, loadBalancerName: targetGroup.loadBalancerNames[0] });
}

private handleShowPopover() {
ReactGA.event({category: 'Cluster Pod', action: `Show Load Balancers Menu`});
ReactGA.event({ category: 'Cluster Pod', action: `Show Load Balancers Menu` });
}

private handleClick(e: React.MouseEvent<HTMLElement>): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class AmazonLoadBalancerDataUtils {
}

const targetGroup: ITargetGroup = { name: match.name, vpcId: match.vpcId, cloudProvider: match.cloudProvider, account: match.account, region: match.region, loadBalancerNames: match.loadBalancerNames } as ITargetGroup;
targetGroup.instanceCounts = {up: 0, down: 0, succeeded: 0, failed: 0, outOfService: 0, unknown: 0, starting: 0};
targetGroup.instanceCounts = { up: 0, down: 0, succeeded: 0, failed: 0, outOfService: 0, unknown: 0, starting: 0 };

serverGroup.instances.forEach(instance => {
const tgHealth: IAmazonHealth = instance.health.find(h => h.type === 'TargetGroup') as IAmazonHealth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ describe('Controller: awsCreateClassicLoadBalancerCtrl', () => {
accountService = _accountService_;
subnetReader = _subnetReader_;
amazonCertificateReader = _amazonCertificateReader_;
const app = applicationModelBuilder.createApplication('app', {key: 'loadBalancers', lazy: true});
const app = applicationModelBuilder.createApplication('app', { key: 'loadBalancers', lazy: true });
initialize = (loadBalancer: IAmazonClassicLoadBalancer = null) => {
if (loadBalancer) {
spyOn(awsLoadBalancerTransformer, 'convertClassicLoadBalancerForEditing').and.returnValue(loadBalancer);
}
controller = $controller<CreateClassicLoadBalancerCtrl>('awsCreateClassicLoadBalancerCtrl', {
$scope: $scope,
$uibModalInstance: {dismiss: noop, result: {then: noop}},
infrastructureCaches: { get: () => { return {getStats: () => {return {}; } }; } },
$uibModalInstance: { dismiss: noop, result: { then: noop } },
infrastructureCaches: { get: () => { return { getStats: () => {return {}; } }; } },
application: app,
loadBalancer: loadBalancer,
isNew: loadBalancer === null,
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('Controller: awsCreateClassicLoadBalancerCtrl', () => {
loadBalancer.listeners.push({ externalProtocol: 'SSL', internalProtocol: 'SSL', internalPort: 80, externalPort: 80 });
expect(controller.showSslCertificateNameField()).toBe(true);

loadBalancer.listeners = [{externalProtocol: 'HTTP', internalProtocol: 'HTTP', internalPort: 80, externalPort: 80 }];
loadBalancer.listeners = [{ externalProtocol: 'HTTP', internalProtocol: 'HTTP', internalPort: 80, externalPort: 80 }];
loadBalancer.listeners.push({ externalProtocol: 'HTTPS', internalProtocol: 'HTTPS', internalPort: 80, externalPort: 80 });
expect(controller.showSslCertificateNameField()).toBe(true);

Expand Down Expand Up @@ -234,10 +234,10 @@ describe('Controller: awsCreateClassicLoadBalancerCtrl', () => {
test: {
aws: {
'us-east-1': [
{name: 'a', id: '1', vpcId: 'vpc-1'},
{name: 'b', id: '2', vpcId: 'vpc-1'},
{name: 'c', id: '3', vpcId: 'vpc-1'},
{name: 'd', id: '4', vpcId: 'vpc-1'}]
{ name: 'a', id: '1', vpcId: 'vpc-1' },
{ name: 'b', id: '2', vpcId: 'vpc-1' },
{ name: 'c', id: '3', vpcId: 'vpc-1' },
{ name: 'd', id: '4', vpcId: 'vpc-1' }]
}
}
};
Expand All @@ -250,8 +250,8 @@ describe('Controller: awsCreateClassicLoadBalancerCtrl', () => {
listeners: [],
} as IAmazonClassicLoadBalancer;
spyOn(securityGroupReader, 'getAllSecurityGroups').and.returnValue($q.when(availableSecurityGroups));
spyOn(accountService, 'getAccountDetails').and.returnValue($q.when([{name: 'test'}]));
spyOn(subnetReader, 'listSubnets').and.returnValue($q.when([{account: 'test', region: 'us-east-1', vpcId: 'vpc-1'}]));
spyOn(accountService, 'getAccountDetails').and.returnValue($q.when([{ name: 'test' }]));
spyOn(subnetReader, 'listSubnets').and.returnValue($q.when([{ account: 'test', region: 'us-east-1', vpcId: 'vpc-1' }]));
spyOn(amazonCertificateReader, 'listCertificates').and.returnValue($q.when([]));
initialize(existingLoadBalancer);
$scope.$digest();
Expand All @@ -265,20 +265,20 @@ describe('Controller: awsCreateClassicLoadBalancerCtrl', () => {
test: {
aws: {
'us-east-1': [
{name: 'a', id: '1', vpcId: 'vpc-1'},
{name: 'b', id: '2', vpcId: 'vpc-1'},
{name: 'c', id: '3', vpcId: 'vpc-1'},
{name: 'd', id: '4', vpcId: 'vpc-1'},
{name: 'sg-a', id: '5', vpcId: 'vpc-1'}]
{ name: 'a', id: '1', vpcId: 'vpc-1' },
{ name: 'b', id: '2', vpcId: 'vpc-1' },
{ name: 'c', id: '3', vpcId: 'vpc-1' },
{ name: 'd', id: '4', vpcId: 'vpc-1' },
{ name: 'sg-a', id: '5', vpcId: 'vpc-1' }]
}
}
};

spyOn(securityGroupReader, 'getAllSecurityGroups').and.returnValue($q.when(availableSecurityGroups));
spyOn(accountService, 'listAccounts').and.returnValue($q.when([{name: 'test'}]));
spyOn(accountService, 'getAccountDetails').and.returnValue($q.when([{name: 'test'}]));
spyOn(accountService, 'listAccounts').and.returnValue($q.when([{ name: 'test' }]));
spyOn(accountService, 'getAccountDetails').and.returnValue($q.when([{ name: 'test' }]));
spyOn(subnetReader, 'listSubnets').and.returnValue($q.when([
{account: 'test', region: 'us-east-1', vpcId: 'vpc-1', purpose: 'external'}
{ account: 'test', region: 'us-east-1', vpcId: 'vpc-1', purpose: 'external' }
]));
spyOn(amazonCertificateReader, 'listCertificates').and.returnValue($q.when([]));
initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class CreateClassicLoadBalancerCtrl extends CreateAmazonLoadBalancerCtrl
}

public addListener(): void {
this.loadBalancerCommand.listeners.push({internalProtocol: 'HTTP', externalProtocol: 'HTTP', externalPort: 80, internalPort: undefined});
this.loadBalancerCommand.listeners.push({ internalProtocol: 'HTTP', externalProtocol: 'HTTP', externalPort: 80, internalPort: undefined });
}

public listenerProtocolChanged(listener: IClassicListenerDescription): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export abstract class CreateAmazonLoadBalancerCtrl {
const existingNames = this.defaultSecurityGroups.filter((name) => this.existingSecurityGroupNames.includes(name));
this.loadBalancerCommand.securityGroups.forEach((securityGroup) => {
if (!this.existingSecurityGroupNames.includes(securityGroup)) {
const matches = filter(this.availableSecurityGroups, {id: securityGroup});
const matches = filter(this.availableSecurityGroups, { id: securityGroup });
if (matches.length) {
existingNames.push(matches[0].name);
} else {
Expand Down Expand Up @@ -270,8 +270,8 @@ export abstract class CreateAmazonLoadBalancerCtrl {
region = this.loadBalancerCommand.region;
return this.subnetReader.listSubnets().then((subnets) => {
return chain(subnets)
.filter({account: account, region: region})
.reject({target: 'ec2'})
.filter({ account: account, region: region })
.reject({ target: 'ec2' })
.value();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Controller: LoadBalancerDetailsCtrl', function () {
applicationModelBuilder: ApplicationModelBuilder) => {
$scope = $rootScope.$new();
$state = _$state_;
const app = applicationModelBuilder.createApplication('app', {key: 'loadBalancers', lazy: true});
const app = applicationModelBuilder.createApplication('app', { key: 'loadBalancers', lazy: true });
app.loadBalancers.data.push(loadBalancer);
controller = $controller(AwsLoadBalancerDetailsController, {
$scope: $scope,
Expand Down Expand Up @@ -67,13 +67,13 @@ describe('Controller: LoadBalancerDetailsCtrl', function () {
});

it('should return the first purpose of subnetDetail if there is only one', function () {
const subnetDetails = [{purpose: 'internal(vpc0)'}] as ISubnet[];
const subnetDetails = [{ purpose: 'internal(vpc0)' }] as ISubnet[];
const result = controller.getFirstSubnetPurpose(subnetDetails);
expect(result).toEqual('internal(vpc0)');
});

it('should return the first purpose of subnetDetail if there are multiple', function () {
const subnetDetails = [{purpose: 'internal(vpc0)'}, {purpose: 'internal(vpc1)'}] as ISubnet[];
const subnetDetails = [{ purpose: 'internal(vpc0)' }, { purpose: 'internal(vpc1)' }] as ISubnet[];
const result = controller.getFirstSubnetPurpose(subnetDetails);
expect(result).toEqual('internal(vpc0)');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class AwsLoadBalancerDetailsController implements IController {
return;
}
this.$state.params.allowModalToStayOpen = true;
this.$state.go('^', null, {location: 'replace'});
this.$state.go('^', null, { location: 'replace' });
}

public extractLoadBalancer(): IPromise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class AwsTargetGroupDetailsController implements IController {
return;
}
this.$state.params.allowModalToStayOpen = true;
this.$state.go('^', null, {location: 'replace'});
this.$state.go('^', null, { location: 'replace' });
}

public extractTargetGroup(): IPromise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class AwsLoadBalancerTransformer {
private normalizeTargetGroup(targetGroup: ITargetGroup): IPromise<ITargetGroup> {
this.normalizeServerGroups(targetGroup.serverGroups, targetGroup, 'targetGroups', 'TargetGroup');

const activeServerGroups = filter(targetGroup.serverGroups, {isDisabled: false});
const activeServerGroups = filter(targetGroup.serverGroups, { isDisabled: false });
targetGroup.provider = targetGroup.type;
targetGroup.instances = chain(activeServerGroups).map('instances').flatten<IInstance>().value();
targetGroup.detachedInstances = chain(activeServerGroups).map('detachedInstances').flatten<IInstance>().value();
Expand All @@ -120,7 +120,7 @@ export class AwsLoadBalancerTransformer {
serverGroups = flatten<IServerGroup>(map(appLoadBalancer.targetGroups, 'serverGroups'));
}

const activeServerGroups = filter(serverGroups, {isDisabled: false});
const activeServerGroups = filter(serverGroups, { isDisabled: false });
loadBalancer.provider = loadBalancer.type;
loadBalancer.instances = chain(activeServerGroups).map('instances').flatten<IInstance>().value();
loadBalancer.detachedInstances = chain(activeServerGroups).map('detachedInstances').flatten<IInstance>().value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('Service: awsServerGroupConfiguration', function () {
spyOn(keyPairsReader, 'listKeyPairs').and.returnValue($q.when([]));
const getAllTypesByRegionSpy = spyOn(awsInstanceTypeService, 'getAllTypesByRegion').and.returnValue($q.when(
{ 'us-east-1': [
{name: 'm4.tiny'}
{ name: 'm4.tiny' }
] }
));
const refreshCacheSpy = spyOn(cacheInitializer, 'refreshCache').and.returnValue($q.when(null));
Expand Down Expand Up @@ -206,15 +206,15 @@ describe('Service: awsServerGroupConfiguration', function () {

expect(this.command.loadBalancers).toEqual([]);
expect(this.command.vpcLoadBalancers).toEqual(['elb-1']);
expect(result).toEqual({ dirty: { }});
expect(result).toEqual({ dirty: { } });
});

it('matches existing load balancers based on name - VPC', function() {
this.command.vpcId = 'vpc-1';
const result = service.configureLoadBalancerOptions(this.command);

expect(this.command.loadBalancers).toEqual(['elb-1']);
expect(result).toEqual({ dirty: { }});
expect(result).toEqual({ dirty: { } });
});

it('sets dirty all unmatched load balancers - no VPC', function () {
Expand All @@ -223,7 +223,7 @@ describe('Service: awsServerGroupConfiguration', function () {
const result = service.configureLoadBalancerOptions(this.command);

expect(this.command.loadBalancers).toEqual(['elb-2']);
expect(result).toEqual({ dirty: { loadBalancers: ['elb-1']}});
expect(result).toEqual({ dirty: { loadBalancers: ['elb-1'] } });
});

it('moves load balancers to vpcLoadBalancers when vpc is de-selected', function () {
Expand All @@ -247,13 +247,13 @@ describe('Service: awsServerGroupConfiguration', function () {
let result = service.configureLoadBalancerOptions(this.command);

expect(this.command.loadBalancers).toEqual(['elb-1']);
expect(result).toEqual({ dirty: { loadBalancers: ['elb-2']}});
expect(result).toEqual({ dirty: { loadBalancers: ['elb-2'] } });

this.command.vpcId = 'vpc-2';
result = service.configureLoadBalancerOptions(this.command);

expect(this.command.loadBalancers).toEqual([]);
expect(result).toEqual({ dirty: { loadBalancers: ['elb-1']}});
expect(result).toEqual({ dirty: { loadBalancers: ['elb-1'] } });
});

it('updates filteredData to new region - no VPC', function() {
Expand All @@ -275,18 +275,18 @@ describe('Service: awsServerGroupConfiguration', function () {
test: {
aws: {
'us-west-1': [
{ name: 'sg1', id: 'sg-1a', vpcId: null},
{ name: 'sg2', id: 'sg-2a', vpcId: null},
{ name: 'sg3', id: 'sg-3a', vpcId: null},
{ name: 'sg1', id: 'sg-1va', vpcId: 'vpc-1'},
{ name: 'sg2', id: 'sg-2va', vpcId: 'vpc-1'},
{ name: 'sg3', id: 'sg-3va', vpcId: 'vpc-2'}
{ name: 'sg1', id: 'sg-1a', vpcId: null },
{ name: 'sg2', id: 'sg-2a', vpcId: null },
{ name: 'sg3', id: 'sg-3a', vpcId: null },
{ name: 'sg1', id: 'sg-1va', vpcId: 'vpc-1' },
{ name: 'sg2', id: 'sg-2va', vpcId: 'vpc-1' },
{ name: 'sg3', id: 'sg-3va', vpcId: 'vpc-2' }
],
'us-east-1': [
{ name: 'sg1', id: 'sg-1c', vpcId: null},
{ name: 'sg2', id: 'sg-2c', vpcId: null},
{ name: 'sg1', id: 'sg-1vc', vpcId: 'vpc-3'},
{ name: 'sg2', id: 'sg-2vc', vpcId: 'vpc-4'}
{ name: 'sg1', id: 'sg-1c', vpcId: null },
{ name: 'sg2', id: 'sg-2c', vpcId: null },
{ name: 'sg1', id: 'sg-1vc', vpcId: 'vpc-3' },
{ name: 'sg2', id: 'sg-2vc', vpcId: 'vpc-4' }
]
}
}
Expand Down Expand Up @@ -316,31 +316,31 @@ describe('Service: awsServerGroupConfiguration', function () {
this.command.vpcId = 'vpc-1';
const result = service.configureSecurityGroupOptions(this.command);
expect(this.command.securityGroups).toEqual(['sg-1va', 'sg-2va']);
expect(result).toEqual({ dirty: { }});
expect(result).toEqual({ dirty: { } });
});

it('matches on name or id, converting to id when name encountered', function() {
this.command.securityGroups = ['sg1', 'sg-2a'];
this.command.region = 'us-east-1';
const result = service.configureSecurityGroupOptions(this.command);
expect(this.command.securityGroups).toEqual(['sg-1c', 'sg-2c']);
expect(result).toEqual({ dirty: {}});
expect(result).toEqual({ dirty: {} });
});

it('sets dirty all unmatched security groups - no VPC', function () {
this.command.securityGroups.push('sg-3a');
this.command.region = 'us-east-1';
const result = service.configureSecurityGroupOptions(this.command);
expect(this.command.securityGroups).toEqual(['sg-1c', 'sg-2c']);
expect(result).toEqual({ dirty: { securityGroups: ['sg3'] }});
expect(result).toEqual({ dirty: { securityGroups: ['sg3'] } });
});

it('sets dirty all unmatched security groups - VPC', function () {
this.command.securityGroups.push('sg-3a');
this.command.vpcId = 'vpc-2';
const result = service.configureSecurityGroupOptions(this.command);
expect(this.command.securityGroups).toEqual(['sg-3va']);
expect(result).toEqual({ dirty: { securityGroups: ['sg1', 'sg2'] }});
expect(result).toEqual({ dirty: { securityGroups: ['sg1', 'sg2'] } });
});

it('updates filteredData to new region - no VPC', function() {
Expand Down
Loading

0 comments on commit 484c91a

Please sign in to comment.