Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified and unified argument collection #430

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'master' of github.com:docker/build-push-action into arg…
…ument-collection
  • Loading branch information
fearphage committed Nov 17, 2021
commit 529b1b6a4bed1654e5d0790a7678bd0ba298c027
6 changes: 3 additions & 3 deletions __tests__/context.test.ts
Original file line number Diff line number Diff line change
@@ -188,9 +188,9 @@ describe('getArgs', () => {
[
'buildx',
'build',
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
'--tag', 'name/app:7.4',
'--tag', 'name/app:latest',
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
'https://github.com/docker/build-push-action.git#refs/heads/test-jest'
]
],
@@ -481,12 +481,12 @@ nproc=3`],
[
'buildx',
'build',
'--ulimit', 'nofile=1024:1024',
'--ulimit', 'nproc=3',
'--cgroup-parent', 'foo',
'--file', './test/Dockerfile',
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
'--shm-size', '2g',
'--ulimit', 'nofile=1024:1024',
'--ulimit', 'nproc=3',
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
'.'
]
38 changes: 7 additions & 31 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 8 additions & 31 deletions src/context.ts
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
}

export async function getArgs(inputs: Inputs, defaultContext: string, buildxVersion: string): Promise<Array<string>> {
return ['buildx', ...(await getBuildArgs(inputs, defaultContext, buildxVersion)), ...(await getCommonArgs(inputs)), inputs.context];
return ['buildx', ...(await getBuildArgs(inputs, defaultContext, buildxVersion)), ...(await getCommonArgs(inputs, buildxVersion)), inputs.context];
}

async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersion: string): Promise<Array<string>> {
@@ -104,31 +104,14 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
...flagMap(inputs.cacheTo, '--cache-to'),
...flagMap(inputs.labels, '--label'),
...flagMap(inputs.outputs, '--output'),
...flagMap(inputs.ssh, '--ssh'),
...flagMap(inputs.tags, '--tag'),
...flagMap(inputs.ssh, '--ssh')
...flagMap(inputs.ulimit, '--ulimit')
);

if (inputs.target) {
args.push('--target', inputs.target);
}
if (inputs.allow.length > 0) {
args.push('--allow', inputs.allow.join(','));
}
if (inputs.platforms.length > 0) {
args.push('--platform', inputs.platforms.join(','));
}
if (!buildx.isLocalOrTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || buildx.satisfies(buildxVersion, '>=0.4.2'))) {
args.push('--iidfile', await buildx.getImageIDFile());
}
if (buildx.satisfies(buildxVersion, '>=0.6.0')) {
args.push('--metadata-file', await buildx.getMetadataFile());
}
await asyncForEach(inputs.cacheFrom, async cacheFrom => {
args.push('--cache-from', cacheFrom);
});
await asyncForEach(inputs.cacheTo, async cacheTo => {
args.push('--cache-to', cacheTo);
});
if (inputs.cgroupParent) {
args.push('--cgroup-parent', inputs.cgroupParent);
}
@@ -138,12 +121,6 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
if (!buildx.isLocalOrTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || buildx.satisfies(buildxVersion, '>=0.4.2'))) {
args.push('--iidfile', await buildx.getImageIDFile());
}
await asyncForEach(inputs.labels, async label => {
args.push('--label', label);
});
await asyncForEach(inputs.outputs, async output => {
args.push('--output', output);
});
if (inputs.platforms.length > 0) {
args.push('--platform', inputs.platforms.join(','));
}
@@ -164,12 +141,12 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && inputs.context == defaultContext) {
args.push('--secret', await buildx.getSecretString(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
}
if (inputs.file) {
args.push('--file', inputs.file);
if (inputs.shmSize) {
args.push('--shm-size', inputs.shmSize);
}
if (inputs.target) {
args.push('--target', inputs.target);
}
await asyncForEach(inputs.ulimit, async ulimit => {
args.push('--ulimit', ulimit);
});
return args;
}

You are viewing a condensed version of this merge commit. You can view the full changes here.