Skip to content

Commit e41efdd

Browse files
committed
buildx: localstate refs
Signed-off-by: CrazyMax <[email protected]>
1 parent 33688c4 commit e41efdd

15 files changed

Lines changed: 117 additions & 1 deletion

__tests__/buildx/buildx.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {Exec} from '../../src/exec';
2626

2727
import {Cert} from '../../src/types/buildx';
2828

29+
const fixturesDir = path.join(__dirname, '..', 'fixtures');
2930
// prettier-ignore
3031
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest');
3132
const tmpName = path.join(tmpDir, '.tmpname-jest');
@@ -252,3 +253,38 @@ describe('resolveCertsDriverOpts', () => {
252253
}
253254
});
254255
});
256+
257+
describe('refs', () => {
258+
it('returns all refs', async () => {
259+
const refs = Buildx.refs({
260+
dir: path.join(fixturesDir, 'buildx-refs')
261+
});
262+
expect(Object.keys(refs).length).toEqual(11);
263+
});
264+
it('returns default builder refs', async () => {
265+
const refs = Buildx.refs({
266+
dir: path.join(fixturesDir, 'buildx-refs'),
267+
builderName: 'default'
268+
});
269+
expect(Object.keys(refs).length).toEqual(8);
270+
});
271+
it('returns foo builder refs', async () => {
272+
const refs = Buildx.refs({
273+
dir: path.join(fixturesDir, 'buildx-refs'),
274+
builderName: 'foo'
275+
});
276+
expect(Object.keys(refs).length).toEqual(3);
277+
});
278+
it('returns default builder refs since', async () => {
279+
const mdate = new Date('2023-09-05T00:00:00Z');
280+
fs.utimesSync(path.join(fixturesDir, 'buildx-refs', 'default', 'default', '36dix0eiv9evr61vrwzn32w7q'), mdate, mdate);
281+
fs.utimesSync(path.join(fixturesDir, 'buildx-refs', 'default', 'default', '49p5r8und2konke5pmlyzqp3n'), mdate, mdate);
282+
fs.utimesSync(path.join(fixturesDir, 'buildx-refs', 'default', 'default', 'a8zqzhhv5yiazm396jobsgdw2'), mdate, mdate);
283+
const refs = Buildx.refs({
284+
dir: path.join(fixturesDir, 'buildx-refs'),
285+
builderName: 'default',
286+
since: new Date('2024-01-10T00:00:00Z')
287+
});
288+
expect(Object.keys(refs).length).toEqual(5);
289+
});
290+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Definition":"eyJncm91cCI6eyJkZWZhdWx0Ijp7InRhcmdldHMiOlsiZGV2Il19fSwidGFyZ2V0Ijp7ImRldiI6eyJjb250ZXh0IjoiLiIsImRvY2tlcmZpbGUiOiJEb2NrZXJmaWxlIiwiYXJncyI6eyJCVUlMREtJVF9DT05URVhUX0tFRVBfR0lUX0RJUiI6IjEiLCJERUZBVUxUX1BST0RVQ1RfTElDRU5TRSI6IiIsIkRPQ0tFUl9CVUlMRFRBR1MiOiIiLCJET0NLRVJfREVCVUciOiIiLCJET0NLRVJfTERGTEFHUyI6IiIsIkRPQ0tFUl9TVEFUSUMiOiIxIiwiUEFDS0FHRVJfTkFNRSI6IiIsIlBMQVRGT1JNIjoiIiwiUFJPRFVDVCI6IiIsIlNZU1RFTUQiOiJmYWxzZSIsIlZFUlNJT04iOiIifSwidGFncyI6WyJkb2NrZXItZGV2Il0sInRhcmdldCI6ImRldiIsIm91dHB1dCI6WyJ0eXBlPWRvY2tlciJdfX19","Targets":["dev"],"Refs":["vzxn0jxr44khtq7hc8drtzwjv"]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"LocalPath":"/home/crazymax/github/docker/docker-alpine-s6","DockerfilePath":""}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"LocalPath":"/home/crazymax/github/docker_org/buildx","DockerfilePath":""}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"LocalPath":"/home/crazymax/github/docker_org/buildx","DockerfilePath":"/home/crazymax/github/docker_org/buildx/Dockerfile"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"LocalPath":"/home/crazymax/github/docker_org/buildx","DockerfilePath":"/home/crazymax/github/docker_org/buildx/Dockerfile"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"LocalPath":"/home/crazymax/github/docker_org/buildx","DockerfilePath":""}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"LocalPath":"/home/crazymax/github/docker_org/buildx","DockerfilePath":"/home/crazymax/github/docker_org/buildx/Dockerfile"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"LocalPath":"/home/crazymax/github/docker_org/buildx","DockerfilePath":""}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Target":"dev","LocalPath":"/home/crazymax/github/docker_org/docker","DockerfilePath":"/home/crazymax/github/docker_org/docker/Dockerfile","GroupRef":"1fugf958r4peyg86h6scim5t5"}

0 commit comments

Comments
 (0)