Skip to content

Commit 020d749

Browse files
committed
chore(config-resolver): update RegionHash and PartitionHash
1 parent 6db17e6 commit 020d749

File tree

6 files changed

+40
-6
lines changed

6 files changed

+40
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { EndpointVariantTag } from "./EndpointVariantTag";
2+
3+
/**
4+
* Provides hostname information for specific host label.
5+
*/
6+
export type EndpointVariant = {
7+
hostname: string;
8+
tags: EndpointVariantTag[];
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* The tag which mentions which area variant is providing information for.
3+
* Can be either "fips" or "dualstack".
4+
*/
5+
export type EndpointVariantTag = "fips" | "dualstack";
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import { EndpointVariant } from "./EndpointVariant";
2+
13
/**
24
* The hash of partition with the information specific to that partition.
35
* The information includes the list of regions belonging to that partition,
46
* and the hostname to be used for the partition.
57
*/
68
export type PartitionHash = {
7-
[key: string]: { regions: string[]; regionRegex: string; hostname?: string; endpoint?: string };
9+
[key: string]: {
10+
regions: string[];
11+
regionRegex: string;
12+
// TODO: Remove hostname after fully switching to variants.
13+
hostname: string;
14+
variants: EndpointVariant[];
15+
endpoint?: string;
16+
};
817
};
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
import { RegionInfo } from "@aws-sdk/types";
1+
import { EndpointVariant } from "./EndpointVariant";
22

33
/**
44
* The hash of region with the information specific to that region.
55
* The information can include hostname, signingService and signingRegion.
66
*/
7-
export type RegionHash = { [key: string]: Partial<Omit<RegionInfo, "partition" | "path">> };
7+
export type RegionHash = {
8+
[key: string]: {
9+
// TODO: Remove hostname after fully switching to variants.
10+
hostname: string;
11+
variants: EndpointVariant[];
12+
signingService?: string;
13+
signingRegion?: string;
14+
};
15+
};

packages/config-resolver/src/regionInfo/getRegionInfo.spec.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ describe(getRegionInfo.name, () => {
2929
...((regionCase === RegionCase.REGION || regionCase === RegionCase.REGION_AND_ENDPOINT) && {
3030
[mockRegion]: {
3131
hostname: mockHostname,
32+
variants: [{ hostname: mockHostname, tags: [] }],
3233
},
3334
}),
3435
...((regionCase === RegionCase.ENDPOINT || regionCase === RegionCase.REGION_AND_ENDPOINT) && {
3536
[mockEndpointRegion]: {
3637
hostname: mockEndpointHostname,
38+
variants: [{ hostname: mockEndpointHostname, tags: [] }],
3739
},
3840
}),
3941
});
@@ -42,9 +44,8 @@ describe(getRegionInfo.name, () => {
4244
[mockPartition]: {
4345
regions: [mockRegion, `${mockRegion}2`, `${mockRegion}3`],
4446
regionRegex: mockRegionRegex,
45-
...((regionCase === RegionCase.REGION || regionCase === RegionCase.REGION_AND_ENDPOINT) && {
46-
hostname: mockHostname,
47-
}),
47+
hostname: mockHostname,
48+
variants: [{ hostname: mockHostname, tags: [] }],
4849
...((regionCase === RegionCase.ENDPOINT || regionCase === RegionCase.REGION_AND_ENDPOINT) && {
4950
endpoint: mockEndpointRegion,
5051
}),

packages/config-resolver/src/regionInfo/getResolvedPartition.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe(getResolvedPartition.name, () => {
1313
regions: [mockRegion, `${mockRegion}2`, `${mockRegion}3`],
1414
regionRegex: mockRegionRegex,
1515
hostname: mockHostname,
16+
variants: [{ hostname: mockHostname, tags: [] }],
1617
},
1718
};
1819
expect(getResolvedPartition(mockRegion, { partitionHash: mockPartitionHash })).toBe(mockPartition);
@@ -24,6 +25,7 @@ describe(getResolvedPartition.name, () => {
2425
regions: [`${mockRegion}2`, `${mockRegion}3`],
2526
regionRegex: mockRegionRegex,
2627
hostname: mockHostname,
28+
variants: [{ hostname: mockHostname, tags: [] }],
2729
},
2830
};
2931
expect(getResolvedPartition(mockRegion, { partitionHash: mockPartitionHash })).toBe("aws");

0 commit comments

Comments
 (0)