Skip to content

Commit ef79e83

Browse files
committed
#299 Make cacheTo an array input
1 parent 80f211c commit ef79e83

File tree

10 files changed

+15
-12
lines changed

10 files changed

+15
-12
lines changed

azdo-task/DevcontainersCi/src/docker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function buildImage(
1212
subFolder: string,
1313
skipContainerUserIdUpdate: boolean,
1414
cacheFrom: string[],
15-
cacheTo: string | undefined,
15+
cacheTo: string[],
1616
): Promise<string> {
1717
console.log('🏗 Building dev container...');
1818
try {

azdo-task/DevcontainersCi/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function runMain(): Promise<void> {
4848
const inputEnvsWithDefaults = populateDefaults(envs, inheritEnv);
4949
const cacheFrom = task.getInput('cacheFrom')?.split('\n') ?? [];
5050
const noCache = (task.getInput('noCache') ?? 'false') === 'true';
51-
const cacheTo = task.getInput('cacheTo') ?? undefined;
51+
const cacheTo = task.getInput('cacheTo')?.split('\n') ?? [];
5252
const skipContainerUserIdUpdate =
5353
(task.getInput('skipContainerUserIdUpdate') ?? 'false') === 'true';
5454

azdo-task/DevcontainersCi/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
},
126126
{
127127
"name": "cacheTo",
128-
"type": "string",
128+
"type": "multiLine",
129129
"label": "Specify the image to cache the built image to",
130130
"required": false
131131
}

common/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface DevContainerConfig {
1515
context?: string;
1616
args?: Record<string, string>;
1717
cacheFrom?: string | string[];
18-
cacheTo?: string;
18+
cacheTo?: string | string[];
1919
};
2020
runArgs?: string[];
2121
mounts?: string[];

common/src/dev-container-cli.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export interface DevContainerCliBuildArgs {
161161
userDataFolder?: string;
162162
output?: string,
163163
noCache?: boolean,
164-
cacheTo?: string,
164+
cacheTo?: string[],
165165
}
166166
async function devContainerBuild(
167167
args: DevContainerCliBuildArgs,
@@ -196,7 +196,9 @@ async function devContainerBuild(
196196
commandArgs.push('--cache-from', cacheFrom),
197197
);
198198
if (args.cacheTo) {
199-
commandArgs.push('--cache-to', args.cacheTo);
199+
args.cacheTo.forEach(cacheTo =>
200+
commandArgs.push('--cache-to', cacheTo),
201+
);
200202
}
201203
}
202204
return await runSpecCliJsonCommand<DevContainerCliBuildResult>({

common/src/docker.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function buildImage(
2121
subFolder: string,
2222
skipContainerUserIdUpdate: boolean,
2323
cacheFrom: string[],
24-
cacheTo: string | undefined,
24+
cacheTo: string[],
2525
): Promise<string> {
2626
const folder = path.join(checkoutPath, subFolder);
2727
const devcontainerJsonPath = path.join(
@@ -63,7 +63,7 @@ async function buildImageBase(
6363
folder: string,
6464
devcontainerConfig: config.DevContainerConfig,
6565
cacheFrom: string[],
66-
cacheTo: string | undefined,
66+
cacheTo: string[],
6767
): Promise<void> {
6868
const configDockerfile = config.getDockerfile(devcontainerConfig);
6969
if (!configDockerfile) {
@@ -89,8 +89,7 @@ async function buildImageBase(
8989
}
9090
cacheFrom.forEach(cacheValue => args.push('--cache-from', cacheValue));
9191
if (cacheTo) {
92-
args.push('--cache-to');
93-
args.push(cacheTo);
92+
cacheTo.forEach(cacheValue => args.push('--cache-to', cacheValue));
9493
} else {
9594
args.push('--cache-to');
9695
args.push('type=inline');

docs/azure-devops-task.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ In the example above, the devcontainer-build-run will perform the following step
8282
| skipContainerUserIdUpdate | false | For non-root Dev Containers (i.e. where `remoteUser` is specified), the action attempts to make the container user UID and GID match those of the host user. Set this to true to skip this step (defaults to false) |
8383
| cacheFrom | false | Specify additional images to use for build caching |
8484
| noCache | false | Builds the image with `--no-cache` (takes precedence over `cacheFrom`) |
85+
| cacheTo | false | Specify the image to cache the built image to |
8586
| platform | false | Platforms for which the image should be built. If omitted, defaults to the platform of the GitHub Actions Runner. Multiple platforms should be comma separated. |
8687

8788
## Outputs

docs/github-action.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ The [`devcontainers/ci` action](https://github.com/marketplace/actions/devcontai
141141
| skipContainerUserIdUpdate | false | For non-root Dev Containers (i.e. where `remoteUser` is specified), the action attempts to make the container user UID and GID match those of the host user. Set this to true to skip this step (defaults to false) |
142142
| cacheFrom | false | Specify additional images to use for build caching |
143143
| noCache | false | Builds the image with `--no-cache` (takes precedence over `cacheFrom`) |
144+
| cacheTo | false | Specify the image to cache the built image to |
144145
| platform | false | Platforms for which the image should be built. If omitted, defaults to the platform of the GitHub Actions Runner. Multiple platforms should be comma separated. |
145146

146147
## Outputs

github-action/src/docker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function buildImage(
1212
subFolder: string,
1313
skipContainerUserIdUpdate: boolean,
1414
cacheFrom: string[],
15-
cacheTo: string | undefined,
15+
cacheTo: string[],
1616
): Promise<string> {
1717
core.startGroup('🏗 Building dev container...');
1818
try {

github-action/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function runMain(): Promise<void> {
5757
const inputEnvsWithDefaults = populateDefaults(inputEnvs, inheritEnv);
5858
const cacheFrom: string[] = core.getMultilineInput('cacheFrom');
5959
const noCache: boolean = core.getBooleanInput('noCache');
60-
const cacheTo = emptyStringAsUndefined(core.getInput('cacheTo'));
60+
const cacheTo: string[] = core.getMultilineInput('cacheFrom');
6161
const skipContainerUserIdUpdate = core.getBooleanInput(
6262
'skipContainerUserIdUpdate',
6363
);

0 commit comments

Comments
 (0)