2
0
Fork 0
mirror of https://code.forgejo.org/docker/metadata-action.git synced 2025-09-17 02:06:56 +00:00
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-03-29 13:04:53 +02:00 committed by GitHub
parent 9be43f076d
commit 2f83320d17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 3016 additions and 528 deletions

42
src/flavor.ts Normal file
View file

@ -0,0 +1,42 @@
export interface Flavor {
latest: string;
prefix: string;
suffix: string;
}
export function Transform(inputs: string[]): Flavor {
const flavor: Flavor = {
latest: 'auto',
prefix: '',
suffix: ''
};
for (const input of inputs) {
const parts = input.split('=', 2);
if (parts.length == 1) {
throw new Error(`Invalid entry: ${input}`);
}
switch (parts[0]) {
case 'latest': {
flavor.latest = parts[1];
if (!['auto', 'true', 'false'].includes(flavor.latest)) {
throw new Error(`Invalid latest flavor entry: ${input}`);
}
break;
}
case 'prefix': {
flavor.prefix = parts[1];
break;
}
case 'suffix': {
flavor.suffix = parts[1];
break;
}
default: {
throw new Error(`Unknown entry: ${input}`);
}
}
}
return flavor;
}