Skip to content

Commit e0e5ecf

Browse files
committed
remove uuid package and switch to crypto
Signed-off-by: CrazyMax <[email protected]>
1 parent 5334dd0 commit e0e5ecf

File tree

5 files changed

+5
-29
lines changed

5 files changed

+5
-29
lines changed

__tests__/context.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
22
import * as fs from 'fs';
33
import * as path from 'path';
4-
import * as uuid from 'uuid';
54
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
65
import {Context} from '@docker/actions-toolkit/lib/context';
76
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
@@ -26,8 +25,7 @@ jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
2625
return tmpName;
2726
});
2827

29-
jest.mock('uuid');
30-
jest.spyOn(uuid, 'v4').mockReturnValue('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d');
28+
jest.spyOn(crypto, 'randomUUID').mockReturnValue('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d');
3129

3230
jest.spyOn(Docker, 'context').mockImplementation((): Promise<string> => {
3331
return Promise.resolve('default');

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@
2727
"dependencies": {
2828
"@actions/core": "^1.10.1",
2929
"@docker/actions-toolkit": "^0.35.0",
30-
"js-yaml": "^4.1.0",
31-
"uuid": "^10.0.0"
30+
"js-yaml": "^4.1.0"
3231
},
3332
"devDependencies": {
3433
"@types/js-yaml": "^4.0.9",
3534
"@types/node": "^20.12.12",
36-
"@types/uuid": "^10.0.0",
3735
"@typescript-eslint/eslint-plugin": "^7.9.0",
3836
"@typescript-eslint/parser": "^7.9.0",
3937
"@vercel/ncc": "^0.38.1",

src/context.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as uuid from 'uuid';
21
import * as core from '@actions/core';
32

43
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
@@ -47,7 +46,7 @@ export async function getInputs(): Promise<Inputs> {
4746
}
4847

4948
export async function getBuilderName(driver: string): Promise<string> {
50-
return driver == 'docker' ? await Docker.context() : `builder-${uuid.v4()}`;
49+
return driver == 'docker' ? await Docker.context() : `builder-${crypto.randomUUID()}`;
5150
}
5251

5352
export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
@@ -84,7 +83,7 @@ export async function getAppendArgs(inputs: Inputs, node: Node, toolkit: Toolkit
8483
if (node.name) {
8584
args.push('--node', node.name);
8685
} else if (inputs.driver == 'kubernetes' && (await toolkit.buildx.versionSatisfies('<0.11.0'))) {
87-
args.push('--node', `node-${uuid.v4()}`);
86+
args.push('--node', `node-${crypto.randomUUID()}`);
8887
}
8988
if (node['driver-opts'] && (await toolkit.buildx.versionSatisfies('>=0.3.0'))) {
9089
await Util.asyncForEach(node['driver-opts'], async (driverOpt: string) => {

src/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as fs from 'fs';
22
import * as yaml from 'js-yaml';
3-
import * as uuid from 'uuid';
43
import * as core from '@actions/core';
54
import * as actionsToolkit from '@docker/actions-toolkit';
65

@@ -98,7 +97,7 @@ actionsToolkit.run(
9897
});
9998
});
10099
if (defaultContextWithTLS) {
101-
const tmpDockerContext = `buildx-${uuid.v4()}`;
100+
const tmpDockerContext = `buildx-${crypto.randomUUID()}`;
102101
await core.group(`Creating temp docker context (TLS data loaded in default one)`, async () => {
103102
await Docker.getExecOutput(['context', 'create', tmpDockerContext], {
104103
ignoreReturnCode: true

yarn.lock

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,13 +2124,6 @@ __metadata:
21242124
languageName: node
21252125
linkType: hard
21262126

2127-
"@types/uuid@npm:^10.0.0":
2128-
version: 10.0.0
2129-
resolution: "@types/uuid@npm:10.0.0"
2130-
checksum: e3958f8b0fe551c86c14431f5940c3470127293280830684154b91dc7eb3514aeb79fe3216968833cf79d4d1c67f580f054b5be2cd562bebf4f728913e73e944
2131-
languageName: node
2132-
linkType: hard
2133-
21342127
"@types/yargs-parser@npm:*":
21352128
version: 20.2.0
21362129
resolution: "@types/yargs-parser@npm:20.2.0"
@@ -3171,7 +3164,6 @@ __metadata:
31713164
"@docker/actions-toolkit": ^0.35.0
31723165
"@types/js-yaml": ^4.0.9
31733166
"@types/node": ^20.12.12
3174-
"@types/uuid": ^10.0.0
31753167
"@typescript-eslint/eslint-plugin": ^7.9.0
31763168
"@typescript-eslint/parser": ^7.9.0
31773169
"@vercel/ncc": ^0.38.1
@@ -3185,7 +3177,6 @@ __metadata:
31853177
ts-jest: ^29.1.2
31863178
ts-node: ^10.9.2
31873179
typescript: ^5.4.5
3188-
uuid: ^10.0.0
31893180
languageName: unknown
31903181
linkType: soft
31913182

@@ -6670,15 +6661,6 @@ __metadata:
66706661
languageName: node
66716662
linkType: hard
66726663

6673-
"uuid@npm:^10.0.0":
6674-
version: 10.0.0
6675-
resolution: "uuid@npm:10.0.0"
6676-
bin:
6677-
uuid: dist/bin/uuid
6678-
checksum: 4b81611ade2885d2313ddd8dc865d93d8dccc13ddf901745edca8f86d99bc46d7a330d678e7532e7ebf93ce616679fb19b2e3568873ac0c14c999032acb25869
6679-
languageName: node
6680-
linkType: hard
6681-
66826664
"uuid@npm:^3.3.2, uuid@npm:^3.3.3":
66836665
version: 3.4.0
66846666
resolution: "uuid@npm:3.4.0"

0 commit comments

Comments
 (0)