Skip to content

Commit f25ff28

Browse files
committed
support dual-stack for aws public ecr
Signed-off-by: CrazyMax <[email protected]>
1 parent e0c62a9 commit f25ff28

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

__tests__/aws.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ describe('isECR', () => {
1111
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', true],
1212
['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', true],
1313
['012345678901.dkr-ecr.eu-north-1.on.aws', true],
14-
['public.ecr.aws', true]
14+
['public.ecr.aws', true],
15+
['ecr-public.aws.com', true]
1516
])('given registry %p', async (registry, expected) => {
1617
expect(aws.isECR(registry)).toEqual(expected);
1718
});
@@ -25,7 +26,8 @@ describe('isPubECR', () => {
2526
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', false],
2627
['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', false],
2728
['012345678901.dkr-ecr.eu-north-1.on.aws', false],
28-
['public.ecr.aws', true]
29+
['public.ecr.aws', true],
30+
['ecr-public.aws.com', true]
2931
])('given registry %p', async (registry, expected) => {
3032
expect(aws.isPubECR(registry)).toEqual(expected);
3133
});

src/aws.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import {HttpProxyAgent} from 'http-proxy-agent';
66
import {HttpsProxyAgent} from 'https-proxy-agent';
77

88
const ecrRegistryRegex = /^(([0-9]{12})\.(dkr\.ecr|dkr-ecr)\.(.+)\.(on\.aws|amazonaws\.com(.cn)?))(\/([^:]+)(:.+)?)?$/;
9+
const ecrPublicRegistryRegex = /public\.ecr\.aws|ecr-public\.aws\.com/;
910

1011
export const isECR = (registry: string): boolean => {
1112
return ecrRegistryRegex.test(registry) || isPubECR(registry);
1213
};
1314

1415
export const isPubECR = (registry: string): boolean => {
15-
return registry === 'public.ecr.aws';
16+
return ecrPublicRegistryRegex.test(registry);
1617
};
1718

1819
export const getRegion = (registry: string): string => {

0 commit comments

Comments
 (0)