mirror of
https://gitee.com/actions-mirror/docker-login-action
synced 2025-08-10 18:02:56 +08:00
Merge pull request #874 from Spacefish/support-new-aws-ecr-endpoint
Support new <registry-id>.dkr-ecr.<aws-region>.on.aws endpoint
This commit is contained in:
commit
e0c62a93a1
@ -10,6 +10,7 @@ describe('isECR', () => {
|
|||||||
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', true],
|
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', true],
|
||||||
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', true],
|
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', true],
|
||||||
['390948362332.dkr.ecr.cn-northwest-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]
|
||||||
])('given registry %p', async (registry, expected) => {
|
])('given registry %p', async (registry, expected) => {
|
||||||
expect(aws.isECR(registry)).toEqual(expected);
|
expect(aws.isECR(registry)).toEqual(expected);
|
||||||
@ -23,6 +24,7 @@ describe('isPubECR', () => {
|
|||||||
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', false],
|
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', false],
|
||||||
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', false],
|
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', false],
|
||||||
['390948362332.dkr.ecr.cn-northwest-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]
|
||||||
])('given registry %p', async (registry, expected) => {
|
])('given registry %p', async (registry, expected) => {
|
||||||
expect(aws.isPubECR(registry)).toEqual(expected);
|
expect(aws.isPubECR(registry)).toEqual(expected);
|
||||||
@ -34,6 +36,7 @@ describe('getRegion', () => {
|
|||||||
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', 'eu-west-3'],
|
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', 'eu-west-3'],
|
||||||
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', 'cn-north-1'],
|
['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', 'cn-north-1'],
|
||||||
['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', 'cn-northwest-1'],
|
['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', 'cn-northwest-1'],
|
||||||
|
['012345678901.dkr-ecr.eu-north-1.on.aws', 'eu-north-1'],
|
||||||
['public.ecr.aws', 'us-east-1']
|
['public.ecr.aws', 'us-east-1']
|
||||||
])('given registry %p', async (registry, expected) => {
|
])('given registry %p', async (registry, expected) => {
|
||||||
expect(aws.getRegion(registry)).toEqual(expected);
|
expect(aws.getRegion(registry)).toEqual(expected);
|
||||||
@ -46,6 +49,7 @@ describe('getAccountIDs', () => {
|
|||||||
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', '012345678910,023456789012', ['012345678901', '012345678910', '023456789012']],
|
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', '012345678910,023456789012', ['012345678901', '012345678910', '023456789012']],
|
||||||
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', '012345678901,012345678910,023456789012', ['012345678901', '012345678910', '023456789012']],
|
['012345678901.dkr.ecr.eu-west-3.amazonaws.com', '012345678901,012345678910,023456789012', ['012345678901', '012345678910', '023456789012']],
|
||||||
['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', '012345678910,023456789012', ['390948362332', '012345678910', '023456789012']],
|
['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', '012345678910,023456789012', ['390948362332', '012345678910', '023456789012']],
|
||||||
|
['876820548815.dkr-ecr.eu-north-1.on.aws', '012345678910,023456789012', ['876820548815', '012345678910', '023456789012']],
|
||||||
['public.ecr.aws', undefined, []]
|
['public.ecr.aws', undefined, []]
|
||||||
])('given registry %p', async (registry, accountIDsEnv, expected) => {
|
])('given registry %p', async (registry, accountIDsEnv, expected) => {
|
||||||
if (accountIDsEnv) {
|
if (accountIDsEnv) {
|
||||||
|
2
dist/index.js
generated
vendored
2
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@ import {NodeHttpHandler} from '@smithy/node-http-handler';
|
|||||||
import {HttpProxyAgent} from 'http-proxy-agent';
|
import {HttpProxyAgent} from 'http-proxy-agent';
|
||||||
import {HttpsProxyAgent} from 'https-proxy-agent';
|
import {HttpsProxyAgent} from 'https-proxy-agent';
|
||||||
|
|
||||||
const ecrRegistryRegex = /^(([0-9]{12})\.dkr\.ecr\.(.+)\.amazonaws\.com(.cn)?)(\/([^:]+)(:.+)?)?$/;
|
const ecrRegistryRegex = /^(([0-9]{12})\.(dkr\.ecr|dkr-ecr)\.(.+)\.(on\.aws|amazonaws\.com(.cn)?))(\/([^:]+)(:.+)?)?$/;
|
||||||
|
|
||||||
export const isECR = (registry: string): boolean => {
|
export const isECR = (registry: string): boolean => {
|
||||||
return ecrRegistryRegex.test(registry) || isPubECR(registry);
|
return ecrRegistryRegex.test(registry) || isPubECR(registry);
|
||||||
@ -23,7 +23,7 @@ export const getRegion = (registry: string): string => {
|
|||||||
if (!matches) {
|
if (!matches) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return matches[3];
|
return matches[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAccountIDs = (registry: string): string[] => {
|
export const getAccountIDs = (registry: string): string[] => {
|
||||||
|
Loading…
Reference in New Issue
Block a user