mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
buildx: make refs dir optional in localState func
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
5b4c1ac025
commit
3bd6acf499
@ -303,7 +303,7 @@ describe('localState', () => {
|
||||
} as LocalState,
|
||||
]
|
||||
])('given %p', async (ref: string, expected: LocalState) => {
|
||||
const localState = Buildx.localState(path.join(fixturesDir, 'buildx-refs'), ref);
|
||||
const localState = Buildx.localState(ref, path.join(fixturesDir, 'buildx-refs'));
|
||||
expect(localState).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
@ -177,12 +177,12 @@ export class Buildx {
|
||||
return driverOpts;
|
||||
}
|
||||
|
||||
public static localState(dir: string, ref: string): LocalState {
|
||||
public static localState(ref: string, dir?: string): LocalState {
|
||||
const [builderName, nodeName, id] = ref.split('/');
|
||||
if (!builderName || !nodeName || !id) {
|
||||
throw new Error(`Invalid build reference: ${ref}`);
|
||||
}
|
||||
const lsPath = path.join(dir, builderName, nodeName, id);
|
||||
const lsPath = path.join(dir || Buildx.refsDir, builderName, nodeName, id);
|
||||
if (!fs.existsSync(lsPath)) {
|
||||
throw new Error(`Local state not found in ${lsPath}`);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user