Skip to content

Commit

Permalink
linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
moofish32 committed Oct 2, 2018
1 parent 913e718 commit baf96fa
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/util/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class SDK {
}
public async route53(awsAccountId: string | undefined, region: string | undefined, mode: Mode): Promise<AWS.Route53> {
return new AWS.Route53({
region: region,
region,
credentials: await this.credentialsCache.get(awsAccountId, mode),
...this.defaultClientArgs
});
Expand Down
63 changes: 33 additions & 30 deletions packages/aws-cdk/lib/contextplugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,48 +76,51 @@ export class HostedZoneContextProviderPlugin implements ContextProviderPlugin {
}
const candidateZones = this.filterZones(r53, response.HostedZones,
!!props.privateZone, props.vpcId);
if(candidateZones.length > 1) {
const filter = `dns:${domainName}, privateZone:${privateZone}, vpcId:${vpcId}`;
throw new Error(`Found more than one matching HostedZone ${candidateZones} for ${filter}`);
if (candidateZones.length > 1) {
const filteProps = `dns:${domainName}, privateZone:${privateZone}, vpcId:${vpcId}`;
throw new Error(`Found more than one matching HostedZone ${candidateZones} for ${filteProps}`);
}
return candidateZones[0];
}
private filterZones(r53: AWS.Route53, zones: AWS.Route53.HostedZone[], privateZone: boolean, vpcId: string | undefined): AWS.Route53.HostedZone[]{
let candidates: AWS.Route53.HostedZone[] = [];
if(privateZone) {
candidates = zones.filter(zone => zone.Config && zone.Config.PrivateZone);
} else {
candidates = zones.filter(zone => !zone.Config || !zone.Config.PrivateZone);
}
if(vpcId) {
const vpcZones: AWS.Route53.HostedZone[] = [];
for(const zone of candidates) {
r53.getHostedZone({Id: zone.Id}, (err, data) => {
if(err) {
throw new Error(err.message);
}
if(!data.VPCs) {
debug(`Expected VPC for private zone but no VPC found ${zone.Id}`)
return;
}
if(data.VPCs.map(vpc => vpc.VPCId).includes(vpcId)) {
vpcZones.push(zone);
}
});

private filterZones(r53: AWS.Route53, zones: AWS.Route53.HostedZone[], privateZone: boolean, vpcId: string | undefined): AWS.Route53.HostedZone[] {

let candidates: AWS.Route53.HostedZone[] = [];
if (privateZone) {
candidates = zones.filter(zone => zone.Config && zone.Config.PrivateZone);
} else {
candidates = zones.filter(zone => !zone.Config || !zone.Config.PrivateZone);
}
return vpcZones;
if (vpcId) {
const vpcZones: AWS.Route53.HostedZone[] = [];
for (const zone of candidates) {
r53.getHostedZone({Id: zone.Id}, (err, data) => {
if (err) {
throw new Error(err.message);
}
if (!data.VPCs) {
debug(`Expected VPC for private zone but no VPC found ${zone.Id}`);
return;
}
if (data.VPCs.map(vpc => vpc.VPCId).includes(vpcId)) {
vpcZones.push(zone);
}
});
}
return vpcZones;
}
return candidates;
}
return candidates;
}

private isHostedZoneProps(props: cxapi.HostedZoneProviderProps | any): props is cxapi.HostedZoneProviderProps {
return (<cxapi.HostedZoneProviderProps>props).domainName !== undefined;
return (props as cxapi.HostedZoneProviderProps).domainName !== undefined;
}
}
/**
* Iterate over the list of missing context values and invoke the appropriate providers from the map to retrieve them
*/
export async function provideContextValues(missingValues: { [key: string]: cxapi.ContextProviderProps },
export async function provideContextValues(
missingValues: { [key: string]: cxapi.ContextProviderProps },
projectConfig: Settings,
availableContextProviders: ProviderMap) {
for (const key of Object.keys(missingValues)) {
Expand Down

0 comments on commit baf96fa

Please sign in to comment.