Skip to content

Commit e0c62a9

Browse files
authored
Merge pull request #874 from Spacefish/support-new-aws-ecr-endpoint
Support new <registry-id>.dkr-ecr.<aws-region>.on.aws endpoint
2 parents 3d10084 + a547b56 commit e0c62a9

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

__tests__/aws.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe('isECR', () => {
1010
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', true],
1111
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', true],
1212
['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', true],
13+
['012345678901.dkr-ecr.eu-north-1.on.aws', true],
1314
['public.ecr.aws', true]
1415
])('given registry %p', async (registry, expected) => {
1516
expect(aws.isECR(registry)).toEqual(expected);
@@ -23,6 +24,7 @@ describe('isPubECR', () => {
2324
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', false],
2425
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', false],
2526
['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', false],
27+
['012345678901.dkr-ecr.eu-north-1.on.aws', false],
2628
['public.ecr.aws', true]
2729
])('given registry %p', async (registry, expected) => {
2830
expect(aws.isPubECR(registry)).toEqual(expected);
@@ -34,6 +36,7 @@ describe('getRegion', () => {
3436
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', 'eu-west-3'],
3537
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', 'cn-north-1'],
3638
['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', 'cn-northwest-1'],
39+
['012345678901.dkr-ecr.eu-north-1.on.aws', 'eu-north-1'],
3740
['public.ecr.aws', 'us-east-1']
3841
])('given registry %p', async (registry, expected) => {
3942
expect(aws.getRegion(registry)).toEqual(expected);
@@ -46,6 +49,7 @@ describe('getAccountIDs', () => {
4649
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', '012345678910,023456789012', ['012345678901', '012345678910', '023456789012']],
4750
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', '012345678901,012345678910,023456789012', ['012345678901', '012345678910', '023456789012']],
4851
['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', '012345678910,023456789012', ['390948362332', '012345678910', '023456789012']],
52+
['876820548815.dkr-ecr.eu-north-1.on.aws', '012345678910,023456789012', ['876820548815', '012345678910', '023456789012']],
4953
['public.ecr.aws', undefined, []]
5054
])('given registry %p', async (registry, accountIDsEnv, expected) => {
5155
if (accountIDsEnv) {

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/aws.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {NodeHttpHandler} from '@smithy/node-http-handler';
55
import {HttpProxyAgent} from 'http-proxy-agent';
66
import {HttpsProxyAgent} from 'https-proxy-agent';
77

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

1010
export const isECR = (registry: string): boolean => {
1111
return ecrRegistryRegex.test(registry) || isPubECR(registry);
@@ -23,7 +23,7 @@ export const getRegion = (registry: string): string => {
2323
if (!matches) {
2424
return '';
2525
}
26-
return matches[3];
26+
return matches[4];
2727
};
2828

2929
export const getAccountIDs = (registry: string): string[] => {

0 commit comments

Comments
 (0)