1
0
Fork 0
mirror of https://github.com/docker/build-push-action.git synced 2025-04-22 14:46:39 +02:00

sort flags

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-11-16 05:19:44 +01:00
parent 04841f2a72
commit 91274a04da
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
4 changed files with 92 additions and 101 deletions

66
dist/index.js generated vendored
View file

@ -298,7 +298,7 @@ function getArgs(inputs, defaultContext, buildxVersion) {
return __awaiter(this, void 0, void 0, function* () {
let args = ['buildx'];
args.push.apply(args, yield getBuildArgs(inputs, defaultContext, buildxVersion));
args.push.apply(args, yield getCommonArgs(inputs));
args.push.apply(args, yield getCommonArgs(inputs, buildxVersion));
args.push(inputs.context);
return args;
});
@ -307,39 +307,33 @@ exports.getArgs = getArgs;
function getBuildArgs(inputs, defaultContext, buildxVersion) {
return __awaiter(this, void 0, void 0, function* () {
let args = ['build'];
yield exports.asyncForEach(inputs.buildArgs, (buildArg) => __awaiter(this, void 0, void 0, function* () {
args.push('--build-arg', buildArg);
}));
yield exports.asyncForEach(inputs.labels, (label) => __awaiter(this, void 0, void 0, function* () {
args.push('--label', label);
}));
yield exports.asyncForEach(inputs.tags, (tag) => __awaiter(this, void 0, void 0, function* () {
args.push('--tag', tag);
}));
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(','));
}
yield exports.asyncForEach(inputs.outputs, (output) => __awaiter(this, void 0, void 0, function* () {
args.push('--output', output);
yield exports.asyncForEach(inputs.buildArgs, (buildArg) => __awaiter(this, void 0, void 0, function* () {
args.push('--build-arg', buildArg);
}));
if (!buildx.isLocalOrTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || buildx.satisfies(buildxVersion, '>=0.4.2'))) {
args.push('--iidfile', yield buildx.getImageIDFile());
}
if (buildx.satisfies(buildxVersion, '>=0.6.0')) {
args.push('--metadata-file', yield buildx.getMetadataFile());
}
yield exports.asyncForEach(inputs.cacheFrom, (cacheFrom) => __awaiter(this, void 0, void 0, function* () {
args.push('--cache-from', cacheFrom);
}));
yield exports.asyncForEach(inputs.cacheTo, (cacheTo) => __awaiter(this, void 0, void 0, function* () {
args.push('--cache-to', cacheTo);
}));
if (inputs.file) {
args.push('--file', inputs.file);
}
if (!buildx.isLocalOrTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || buildx.satisfies(buildxVersion, '>=0.4.2'))) {
args.push('--iidfile', yield buildx.getImageIDFile());
}
yield exports.asyncForEach(inputs.labels, (label) => __awaiter(this, void 0, void 0, function* () {
args.push('--label', label);
}));
yield exports.asyncForEach(inputs.outputs, (output) => __awaiter(this, void 0, void 0, function* () {
args.push('--output', output);
}));
if (inputs.platforms.length > 0) {
args.push('--platform', inputs.platforms.join(','));
}
yield exports.asyncForEach(inputs.secrets, (secret) => __awaiter(this, void 0, void 0, function* () {
try {
args.push('--secret', yield buildx.getSecretString(secret));
@ -362,30 +356,36 @@ function getBuildArgs(inputs, defaultContext, buildxVersion) {
yield exports.asyncForEach(inputs.ssh, (ssh) => __awaiter(this, void 0, void 0, function* () {
args.push('--ssh', ssh);
}));
if (inputs.file) {
args.push('--file', inputs.file);
yield exports.asyncForEach(inputs.tags, (tag) => __awaiter(this, void 0, void 0, function* () {
args.push('--tag', tag);
}));
if (inputs.target) {
args.push('--target', inputs.target);
}
return args;
});
}
function getCommonArgs(inputs) {
function getCommonArgs(inputs, buildxVersion) {
return __awaiter(this, void 0, void 0, function* () {
let args = [];
if (inputs.noCache) {
args.push('--no-cache');
}
if (inputs.builder) {
args.push('--builder', inputs.builder);
}
if (inputs.pull) {
args.push('--pull');
}
if (inputs.load) {
args.push('--load');
}
if (buildx.satisfies(buildxVersion, '>=0.6.0')) {
args.push('--metadata-file', yield buildx.getMetadataFile());
}
if (inputs.network) {
args.push('--network', inputs.network);
}
if (inputs.noCache) {
args.push('--no-cache');
}
if (inputs.pull) {
args.push('--pull');
}
if (inputs.push) {
args.push('--push');
}