Skip to content

Commit

Permalink
REFACTOR: Rename aliases to monikers
Browse files Browse the repository at this point in the history
- Updating the name from aliases to monikers as getAlias in the prior version has a few specific meanings
  • Loading branch information
ericmaino committed Feb 17, 2021
1 parent bec0cdf commit 277e727
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/conversion/azure/azure_converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class AzureConverter {

itemsToMap.push(item);

for (const index of converter.aliases(item)) {
for (const index of converter.monikers(item)) {
if (index.item) {
this.entityStore.registerEntity(index.item, index.alias);
}
Expand Down
4 changes: 2 additions & 2 deletions src/conversion/azure/base_azure_converter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AnyAzureObject, IAzureConverter, ItemAlias} from '.';
import {AnyAzureObject, IAzureConverter, ItemMoniker} from '.';
import {IEntityStore, IRules} from '..';
import {NodeSpec} from '../..';

Expand All @@ -9,7 +9,7 @@ export abstract class BaseAzureConverter implements IAzureConverter {
this.supportedType = supportedType;
}

aliases(item: AnyAzureObject): ItemAlias[] {
monikers(item: AnyAzureObject): ItemMoniker[] {
return [{item, alias: item.name}];
}

Expand Down
4 changes: 2 additions & 2 deletions src/conversion/azure/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import {AnyAzureObject} from '.';
import {IEntityStore, IRules} from '..';
import {NodeSpec} from '../..';

export interface ItemAlias {
export interface ItemMoniker {
readonly item: AnyAzureObject | undefined;
readonly alias: string;
}

export interface IAzureConverter {
readonly supportedType: string;
aliases(input: AnyAzureObject): ItemAlias[];
monikers(input: AnyAzureObject): ItemMoniker[];
convert(
input: AnyAzureObject,
stores: IEntityStore<AnyAzureObject>
Expand Down
10 changes: 5 additions & 5 deletions src/conversion/azure/converter_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
BaseAzureConverter,
IAzureConverter,
AnyAzureObject,
ItemAlias,
ItemMoniker,
} from '.';

export class ConverterStore {
Expand Down Expand Up @@ -32,12 +32,12 @@ class DefaultConverter extends BaseAzureConverter {
super('DefaultTypes*');
}

aliases(input: AnyAzureObject): ItemAlias[] {
const aliases: ItemAlias[] = [];
aliases.push({
monikers(input: AnyAzureObject): ItemMoniker[] {
const monikers: ItemMoniker[] = [];
monikers.push({
item: input,
alias: '',
});
return aliases;
return monikers;
}
}
12 changes: 6 additions & 6 deletions src/conversion/azure/network_interface_converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ConverterStore,
AzureNetworkInterface,
BaseAzureConverter,
ItemAlias,
ItemMoniker,
LocalIpConverter,
PublicIpConverter,
} from '.';
Expand All @@ -21,24 +21,24 @@ export class NetworkInterfaceConverter extends BaseAzureConverter {
);
}

aliases(input: AnyAzureObject): ItemAlias[] {
const aliases = super.aliases(input);
monikers(input: AnyAzureObject): ItemMoniker[] {
const monikers = super.monikers(input);
const nic = input as AzureNetworkInterface;

for (const config of nic.properties.ipConfigurations) {
const converter = this.ipConverters.asConverter(config);

if (converter) {
for (const alias of converter.aliases(config)) {
aliases.push({
for (const alias of converter.monikers(config)) {
monikers.push({
item: alias.item,
alias: `${nic.name}/${alias.alias}`,
});
}
}
}

return aliases;
return monikers;
}

convert(
Expand Down
10 changes: 5 additions & 5 deletions src/conversion/azure/subnet_converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
PublicIpConverter,
} from '.';
import {AzureNetworkSecurityGroup, AzureVirtualNetwork} from './schema';
import {IEntityStore, ItemAlias} from '..';
import {IEntityStore, ItemMoniker} from '..';

export class SubnetConverter extends BaseAzureConverter {
private readonly converters: ConverterStore;
Expand All @@ -30,13 +30,13 @@ export class SubnetConverter extends BaseAzureConverter {
return path.dirname(path.dirname(id));
}

aliases(input: AnyAzureObject): ItemAlias[] {
const aliases: ItemAlias[] = [];
aliases.push({
monikers(input: AnyAzureObject): ItemMoniker[] {
const monikers: ItemMoniker[] = [];
monikers.push({
item: input,
alias: `${input.name}/router`,
});
return aliases;
return monikers;
}

convert(
Expand Down
12 changes: 6 additions & 6 deletions src/conversion/azure/virtual_network_converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
parseIp,
} from '../..';
import {ForwardRuleSpecEx, NodeSpec, SymbolStore} from '../../graph';
import {IAzureConverter, ItemAlias} from './contracts';
import {IAzureConverter, ItemMoniker} from './contracts';
import {AnyAzureObject, AzureVirtualNetwork} from './schema';
import {BaseAzureConverter} from './base_azure_converter';
import {SubnetConverter} from './subnet_converter';
Expand All @@ -27,17 +27,17 @@ export class VirtualNetworkConverter extends BaseAzureConverter {
this.vnets = new Map<string, string>();
}

aliases(input: AnyAzureObject): ItemAlias[] {
const aliases = super.aliases(input);
monikers(input: AnyAzureObject): ItemMoniker[] {
const monikers = super.monikers(input);
const vnet = input as AzureVirtualNetwork;

for (const subnet of vnet.properties.subnets) {
for (const alias of this.subnetConveter.aliases(subnet)) {
aliases.push(alias);
for (const alias of this.subnetConveter.monikers(subnet)) {
monikers.push(alias);
}
}

return aliases;
return monikers;
}

convert(
Expand Down
14 changes: 7 additions & 7 deletions test/conversion/convert_azure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ describe('Conversion - Convert Azure', () => {
type: 'microsoft.network/networkinterfaces',
} as AzureNetworkInterface;

it('Aliases for NIC with single ip', () => {
const aliases = nicConverter.aliases(input);
assert.equal(aliases[0].alias, 'testingcreds68');
assert.equal(aliases[1].alias, 'testingcreds68/ipconfig1');
it('Monikers for NIC with single ip', () => {
const monikers = nicConverter.monikers(input);
assert.equal(monikers[0].alias, 'testingcreds68');
assert.equal(monikers[1].alias, 'testingcreds68/ipconfig1');
});

it('Conversion of NIC with single', () => {
Expand All @@ -62,7 +62,7 @@ describe('Conversion - Convert Azure', () => {
},
];

for (const data of nicConverter.aliases(input)) {
for (const data of nicConverter.monikers(input)) {
if (data.item) {
store.registerEntity(data.item, data.alias);
}
Expand Down Expand Up @@ -145,15 +145,15 @@ describe('Conversion - Convert Azure', () => {
assert.equal(result, expected);
});

it('Subnet aliases should be consistent', () => {
it('Subnet monikers should be consistent', () => {
const expected = [
{
item: inputSubnet,
alias: 'A/router',
},
];

const result = converter.aliases(inputSubnet);
const result = converter.monikers(inputSubnet);
assert.deepEqual(result, expected);
});
});
Expand Down

0 comments on commit 277e727

Please sign in to comment.