From f25ff28d1c8cd9a7c35896711238fed682755e1c Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Fri, 1 Aug 2025 14:27:31 +0200 Subject: [PATCH] support dual-stack for aws public ecr Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- __tests__/aws.test.ts | 6 ++++-- src/aws.ts | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/__tests__/aws.test.ts b/__tests__/aws.test.ts index 807848c..56ed2c3 100644 --- a/__tests__/aws.test.ts +++ b/__tests__/aws.test.ts @@ -11,7 +11,8 @@ describe('isECR', () => { ['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', true], ['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', true], ['012345678901.dkr-ecr.eu-north-1.on.aws', true], - ['public.ecr.aws', true] + ['public.ecr.aws', true], + ['ecr-public.aws.com', true] ])('given registry %p', async (registry, expected) => { expect(aws.isECR(registry)).toEqual(expected); }); @@ -25,7 +26,8 @@ describe('isPubECR', () => { ['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', false], ['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', false], ['012345678901.dkr-ecr.eu-north-1.on.aws', false], - ['public.ecr.aws', true] + ['public.ecr.aws', true], + ['ecr-public.aws.com', true] ])('given registry %p', async (registry, expected) => { expect(aws.isPubECR(registry)).toEqual(expected); }); diff --git a/src/aws.ts b/src/aws.ts index feb0452..be2177d 100644 --- a/src/aws.ts +++ b/src/aws.ts @@ -6,13 +6,14 @@ import {HttpProxyAgent} from 'http-proxy-agent'; import {HttpsProxyAgent} from 'https-proxy-agent'; const ecrRegistryRegex = /^(([0-9]{12})\.(dkr\.ecr|dkr-ecr)\.(.+)\.(on\.aws|amazonaws\.com(.cn)?))(\/([^:]+)(:.+)?)?$/; +const ecrPublicRegistryRegex = /public\.ecr\.aws|ecr-public\.aws\.com/; export const isECR = (registry: string): boolean => { return ecrRegistryRegex.test(registry) || isPubECR(registry); }; export const isPubECR = (registry: string): boolean => { - return registry === 'public.ecr.aws'; + return ecrPublicRegistryRegex.test(registry); }; export const getRegion = (registry: string): string => {