mirror of
https://github.com/redhat-actions/buildah-build.git
synced 2025-06-08 10:01:34 +00:00
Add manifest feature (#85)
* Add manifest feature Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
c7ca484deb
commit
3ffbc5da4f
10 changed files with 227 additions and 69 deletions
62
src/utils.ts
62
src/utils.ts
|
@ -65,24 +65,50 @@ export function splitByNewline(s: string): string[] {
|
|||
return s.split(/\r?\n/);
|
||||
}
|
||||
|
||||
export function getArch(): string {
|
||||
// 'arch' should be used over 'archs', see https://github.com/redhat-actions/buildah-build/issues/60
|
||||
const archs = core.getInput(Inputs.ARCHS);
|
||||
export function getArch(): string[] {
|
||||
const archs = getCommaSeperatedInput(Inputs.ARCHS);
|
||||
|
||||
const arch = core.getInput(Inputs.ARCH);
|
||||
|
||||
if (arch && archs) {
|
||||
if (arch && archs.length > 0) {
|
||||
core.warning(
|
||||
`Both "${Inputs.ARCH}" and "${Inputs.ARCHS}" inputs are set. `
|
||||
+ `Please use only one of these two inputs, as they are aliases of one another. `
|
||||
+ `"${Inputs.ARCH}" takes precedence.`
|
||||
+ `Please use "${Inputs.ARCH}" if you want to provide multiple `
|
||||
+ `ARCH else use ${Inputs.ARCH}". "${Inputs.ARCHS}" takes preference.`
|
||||
);
|
||||
}
|
||||
|
||||
return arch || archs;
|
||||
if (archs.length > 0) {
|
||||
return archs;
|
||||
}
|
||||
else if (arch) {
|
||||
return [ arch ];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
export function getPlatform(): string {
|
||||
return core.getInput(Inputs.PLATFORM);
|
||||
export function getPlatform(): string[] {
|
||||
const platform = core.getInput(Inputs.PLATFORM);
|
||||
const platforms = getCommaSeperatedInput(Inputs.PLATFORMS);
|
||||
|
||||
if (platform && platforms.length > 0) {
|
||||
core.warning(
|
||||
`Both "${Inputs.PLATFORM}" and "${Inputs.PLATFORMS}" inputs are set. `
|
||||
+ `Please use "${Inputs.PLATFORMS}" if you want to provide multiple `
|
||||
+ `PLATFORM else use ${Inputs.PLATFORM}". "${Inputs.PLATFORMS}" takes preference.`
|
||||
);
|
||||
}
|
||||
|
||||
if (platforms.length > 0) {
|
||||
core.debug("return platforms");
|
||||
return platforms;
|
||||
}
|
||||
else if (platform) {
|
||||
core.debug("return platform");
|
||||
return [ platform ];
|
||||
}
|
||||
core.debug("return empty");
|
||||
return [];
|
||||
}
|
||||
|
||||
export function getContainerfiles(): string[] {
|
||||
|
@ -115,6 +141,20 @@ export function getInputList(name: string): string[] {
|
|||
);
|
||||
}
|
||||
|
||||
export function getCommaSeperatedInput(name: string): string[] {
|
||||
const items = core.getInput(name);
|
||||
if (items.length === 0) {
|
||||
core.debug("empty");
|
||||
return [];
|
||||
}
|
||||
const splitItems = items.split(",");
|
||||
return splitItems
|
||||
.reduce<string[]>(
|
||||
(acc, line) => acc.concat(line).map((item) => item.trim()),
|
||||
[],
|
||||
);
|
||||
}
|
||||
|
||||
export function isFullImageName(image: string): boolean {
|
||||
return image.indexOf(":") > 0;
|
||||
}
|
||||
|
@ -125,3 +165,7 @@ export function getFullImageName(image: string, tag: string): string {
|
|||
}
|
||||
return `${image}:${tag}`;
|
||||
}
|
||||
|
||||
export function removeIllegalCharacters(item: string): string {
|
||||
return item.replace(/[^a-zA-Z0-9 ]/g, "");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue