Skip to content

Commit e039495

Browse files
authored
Merge pull request #754 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.35.0
build(deps): bump @docker/actions-toolkit from 0.24.0 to 0.35.0
2 parents e80ebca + 9af18aa commit e039495

File tree

7 files changed

+3284
-477
lines changed

7 files changed

+3284
-477
lines changed

__tests__/docker.test.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import {expect, jest, test} from '@jest/globals';
22
import * as path from 'path';
33

44
import {loginStandard, logout} from '../src/docker';
5-
import {Exec} from '@docker/actions-toolkit/lib/exec';
5+
6+
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
67

78
process.env['RUNNER_TEMP'] = path.join(__dirname, 'runner');
89

910
test('loginStandard calls exec', async () => {
1011
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1112
// @ts-ignore
12-
const execSpy = jest.spyOn(Exec, 'getExecOutput').mockImplementation(async () => {
13+
const execSpy = jest.spyOn(Docker, 'getExecOutput').mockImplementation(async () => {
1314
return {
1415
exitCode: expect.any(Number),
1516
stdout: expect.any(Function),
@@ -23,7 +24,13 @@ test('loginStandard calls exec', async () => {
2324

2425
await loginStandard(registry, username, password);
2526

26-
expect(execSpy).toHaveBeenCalledWith(`docker`, ['login', '--password-stdin', '--username', username, registry], {
27+
expect(execSpy).toHaveBeenCalledTimes(1);
28+
const callfunc = execSpy.mock.calls[0];
29+
if (callfunc && callfunc[1]) {
30+
// we don't want to check env opt
31+
callfunc[1].env = undefined;
32+
}
33+
expect(execSpy).toHaveBeenCalledWith(['login', '--password-stdin', '--username', username, registry], {
2734
input: Buffer.from(password),
2835
silent: true,
2936
ignoreReturnCode: true
@@ -33,7 +40,7 @@ test('loginStandard calls exec', async () => {
3340
test('logout calls exec', async () => {
3441
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
3542
// @ts-ignore
36-
const execSpy = jest.spyOn(Exec, 'getExecOutput').mockImplementation(async () => {
43+
const execSpy = jest.spyOn(Docker, 'getExecOutput').mockImplementation(async () => {
3744
return {
3845
exitCode: expect.any(Number),
3946
stdout: expect.any(Function),
@@ -45,7 +52,13 @@ test('logout calls exec', async () => {
4552

4653
await logout(registry);
4754

48-
expect(execSpy).toHaveBeenCalledWith(`docker`, ['logout', registry], {
55+
expect(execSpy).toHaveBeenCalledTimes(1);
56+
const callfunc = execSpy.mock.calls[0];
57+
if (callfunc && callfunc[1]) {
58+
// we don't want to check env opt
59+
callfunc[1].env = undefined;
60+
}
61+
expect(execSpy).toHaveBeenCalledWith(['logout', registry], {
4962
ignoreReturnCode: true
5063
});
5164
});

dist/index.js

+91-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/licenses.txt

+3,008-444
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@actions/core": "^1.10.1",
2929
"@aws-sdk/client-ecr": "^3.583.0",
3030
"@aws-sdk/client-ecr-public": "^3.583.0",
31-
"@docker/actions-toolkit": "^0.24.0",
31+
"@docker/actions-toolkit": "^0.35.0",
3232
"http-proxy-agent": "^7.0.2",
3333
"https-proxy-agent": "^7.0.4"
3434
},

src/docker.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as aws from './aws';
22
import * as core from '@actions/core';
3-
import {Exec} from '@docker/actions-toolkit/lib/exec';
3+
4+
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
45

56
export async function login(registry: string, username: string, password: string, ecr: string): Promise<void> {
67
if (/true/i.test(ecr) || (ecr == 'auto' && aws.isECR(registry))) {
@@ -11,7 +12,7 @@ export async function login(registry: string, username: string, password: string
1112
}
1213

1314
export async function logout(registry: string): Promise<void> {
14-
await Exec.getExecOutput('docker', ['logout', registry], {
15+
await Docker.getExecOutput(['logout', registry], {
1516
ignoreReturnCode: true
1617
}).then(res => {
1718
if (res.stderr.length > 0 && res.exitCode != 0) {
@@ -40,7 +41,7 @@ export async function loginStandard(registry: string, username: string, password
4041
} else {
4142
core.info(`Logging into Docker Hub...`);
4243
}
43-
await Exec.getExecOutput('docker', loginArgs, {
44+
await Docker.getExecOutput(loginArgs, {
4445
ignoreReturnCode: true,
4546
silent: true,
4647
input: Buffer.from(password)
@@ -57,7 +58,7 @@ export async function loginECR(registry: string, username: string, password: str
5758
const regDatas = await aws.getRegistriesData(registry, username, password);
5859
for (const regData of regDatas) {
5960
core.info(`Logging into ${regData.registry}...`);
60-
await Exec.getExecOutput('docker', ['login', '--password-stdin', '--username', regData.username, regData.registry], {
61+
await Docker.getExecOutput(['login', '--password-stdin', '--username', regData.username, regData.registry], {
6162
ignoreReturnCode: true,
6263
silent: true,
6364
input: Buffer.from(regData.password)

0 commit comments

Comments
 (0)