Skip manifest creation if single arch/platform is provided (#88)

Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
Divyanshu Agrawal 2021-11-24 10:38:34 +05:30 committed by GitHub
parent 72b90216e8
commit 5ca1dab81f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 19 deletions

View file

@ -74,7 +74,7 @@ export async function run(): Promise<void> {
builtImage.push(...await doBuildFromScratch(cli, newImage, useOCI, archs, labelsList));
}
if ((archs.length > 0) || (platforms.length > 0)) {
if ((archs.length > 1) || (platforms.length > 1)) {
core.info(`Creating manifest with tag${tagsList.length !== 1 ? "s" : ""} "${tagsList.join(", ")}"`);
const builtManifest = [];
for (const tag of tagsList) {
@ -137,23 +137,39 @@ async function doBuildUsingContainerFiles(
// therefore, appending arch/platform in the tag
if (archs.length > 0 || platforms.length > 0) {
for (const arch of archs) {
const tagSuffix = removeIllegalCharacters(arch);
// handling it seperately as, there is no need of
// tagSuffix if only one image has to be built
let tagSuffix = "";
if (archs.length > 1) {
tagSuffix = `-${removeIllegalCharacters(arch)}`;
}
await cli.buildUsingDocker(
`${newImage}-${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
`${newImage}${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
useOCI, labels, layers, buildahBudExtraArgs, arch, undefined
);
builtImage.push(`${newImage}-${tagSuffix}`);
builtImage.push(`${newImage}${tagSuffix}`);
}
for (const platform of platforms) {
const tagSuffix = removeIllegalCharacters(platform);
let tagSuffix = "";
if (platforms.length > 1) {
tagSuffix = `-${removeIllegalCharacters(platform)}`;
}
await cli.buildUsingDocker(
`${newImage}-${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
`${newImage}${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
useOCI, labels, layers, buildahBudExtraArgs, undefined, platform
);
builtImage.push(`${newImage}-${tagSuffix}`);
builtImage.push(`${newImage}${tagSuffix}`);
}
}
else if (archs.length === 1 || platforms.length === 1) {
await cli.buildUsingDocker(
newImage, context, containerFileAbsPaths, buildArgs,
useOCI, labels, layers, buildahBudExtraArgs, archs[0], platforms[0]
);
builtImage.push(newImage);
}
else {
await cli.buildUsingDocker(
newImage, context, containerFileAbsPaths, buildArgs,
@ -183,7 +199,10 @@ async function doBuildFromScratch(
const builtImage = [];
if (archs.length > 0) {
for (const arch of archs) {
const tagSuffix = removeIllegalCharacters(arch);
let tagSuffix = "";
if (archs.length > 1) {
tagSuffix = `-${removeIllegalCharacters(arch)}`;
}
const newImageConfig: BuildahConfigSettings = {
entrypoint,
port,
@ -194,8 +213,8 @@ async function doBuildFromScratch(
};
await cli.config(containerId, newImageConfig);
await cli.copy(containerId, content);
await cli.commit(containerId, `${newImage}-${tagSuffix}`, useOCI);
builtImage.push(`${newImage}-${tagSuffix}`);
await cli.commit(containerId, `${newImage}${tagSuffix}`, useOCI);
builtImage.push(`${newImage}${tagSuffix}`);
}
}
else {