Add example for Azure Container Registry (ACR)

This commit is contained in:
CrazyMax 2020-08-21 16:29:54 +02:00
parent 1bd3567034
commit e56233ce43
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
5 changed files with 52 additions and 20 deletions

View file

@ -14,7 +14,7 @@ export const getCLI = async (): Promise<string> => {
return io.which('aws', true);
};
export const getCLICmdOutput = async (args: string[]): Promise<string> => {
export const execCLI = async (args: string[]): Promise<string> => {
return execm.exec(await getCLI(), args, true).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
@ -27,7 +27,7 @@ export const getCLICmdOutput = async (args: string[]): Promise<string> => {
};
export const getCLIVersion = async (): Promise<string> => {
return parseCLIVersion(await getCLICmdOutput(['--version']));
return parseCLIVersion(await execCLI(['--version']));
};
export const parseCLIVersion = async (stdout: string): Promise<string> => {
@ -38,13 +38,13 @@ export const parseCLIVersion = async (stdout: string): Promise<string> => {
return semver.clean(matches[1]);
};
export const getECRLoginCmd = async (cliVersion: string, registry: string, region: string): Promise<string> => {
export const getDockerLoginCmd = async (cliVersion: string, registry: string, region: string): Promise<string> => {
if (semver.satisfies(cliVersion, '>=2.0.0')) {
return getCLICmdOutput(['ecr', 'get-login-password', '--region', region]).then(pwd => {
return execCLI(['ecr', 'get-login-password', '--region', region]).then(pwd => {
return `docker login --username AWS --password ${pwd} ${registry}`;
});
} else {
return getCLICmdOutput(['ecr', 'get-login', '--region', region, '--no-include-email']).then(dockerLoginCmd => {
return execCLI(['ecr', 'get-login', '--region', region, '--no-include-email']).then(dockerLoginCmd => {
return dockerLoginCmd;
});
}