From d29f4810682337a28d7d000ec0831abae63e210c Mon Sep 17 00:00:00 2001 From: Sebastian Steins <592313+sebst@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:09:21 +0200 Subject: [PATCH] #299 Make `cacheTo` available to `devcontainer up` and make it independant of `noCache` --- common/src/dev-container-cli.ts | 16 +++++++++++----- common/src/docker.ts | 4 +++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/common/src/dev-container-cli.ts b/common/src/dev-container-cli.ts index c318415e..4ad248d2 100644 --- a/common/src/dev-container-cli.ts +++ b/common/src/dev-container-cli.ts @@ -195,11 +195,11 @@ async function devContainerBuild( args.additionalCacheFroms.forEach(cacheFrom => commandArgs.push('--cache-from', cacheFrom), ); - if (args.cacheTo) { - args.cacheTo.forEach(cacheTo => - commandArgs.push('--cache-to', cacheTo), - ); - } + } + if (args.cacheTo) { + args.cacheTo.forEach(cacheTo => + commandArgs.push('--cache-to', cacheTo), + ); } return await runSpecCliJsonCommand({ args: commandArgs, @@ -217,6 +217,7 @@ export interface DevContainerCliUpArgs { workspaceFolder: string; configFile: string | undefined; additionalCacheFroms?: string[]; + cacheTo?: string[]; skipContainerUserIdUpdate?: boolean; env?: string[]; userDataFolder?: string; @@ -241,6 +242,11 @@ async function devContainerUp( commandArgs.push('--cache-from', cacheFrom), ); } + if (args.cacheTo) { + args.cacheTo.forEach(cacheTo => + commandArgs.push('--cache-to', cacheTo), + ); + } if (args.userDataFolder) { commandArgs.push("--user-data-folder", args.userDataFolder); } diff --git a/common/src/docker.ts b/common/src/docker.ts index 888e598a..fa640781 100644 --- a/common/src/docker.ts +++ b/common/src/docker.ts @@ -89,7 +89,9 @@ async function buildImageBase( } cacheFrom.forEach(cacheValue => args.push('--cache-from', cacheValue)); if (cacheTo) { - cacheTo.forEach(cacheValue => args.push('--cache-to', cacheValue)); + coerceToArray(cacheTo).forEach(cacheValue => + args.push('--cache-to', cacheValue), + ); } else { args.push('--cache-to'); args.push('type=inline');