1
0
Fork 0
mirror of https://github.com/docker/setup-buildx-action.git synced 2025-06-28 08:16:42 +02:00

check if driver compatible with keep-state

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2025-06-13 18:06:00 +02:00
parent 4143b5899b
commit 36590ad0c1
No known key found for this signature in database
GPG key ID: ADE44D8C9D44FBE4
4 changed files with 33 additions and 29 deletions

View file

@ -42,17 +42,14 @@ export async function getInputs(): Promise<Inputs> {
buildkitdConfig: core.getInput('buildkitd-config') || core.getInput('config'),
buildkitdConfigInline: core.getInput('buildkitd-config-inline') || core.getInput('config-inline'),
append: core.getInput('append'),
keepState: core.getBooleanInput('keep-state'),
cacheBinary: core.getBooleanInput('cache-binary'),
cleanup: core.getBooleanInput('cleanup'),
keepState: core.getBooleanInput('keep-state')
cleanup: core.getBooleanInput('cleanup')
};
}
export async function getBuilderName(name: string, driver: string): Promise<string> {
if (driver == 'docker') {
return await Docker.context();
}
return name || `builder-${crypto.randomUUID()}`;
return driver == 'docker' ? await Docker.context() : name || `builder-${crypto.randomUUID()}`;
}
export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {

View file

@ -28,6 +28,12 @@ actionsToolkit.run(
const standalone = await toolkit.buildx.isStandalone();
stateHelper.setStandalone(standalone);
if (inputs.keepState && inputs.driver !== 'docker-container') {
// https://docs.docker.com/reference/cli/docker/buildx/rm/#keep-state
throw new Error(`Cannot use keep-state with ${inputs.driver} driver`);
}
stateHelper.setKeepState(inputs.keepState);
await core.group(`Docker info`, async () => {
try {
await Docker.printVersion();
@ -115,7 +121,6 @@ actionsToolkit.run(
});
}
}
stateHelper.setKeepState(inputs.keepState);
if (inputs.driver !== 'docker') {
await core.group(`Creating a new builder instance`, async () => {