fix issue with property field name

Signed-off-by: Luca Stocchi <lstocchi@redhat.com>
This commit is contained in:
Luca Stocchi 2020-11-13 15:37:29 +01:00
parent e5afab8b69
commit c977b29e3f
No known key found for this signature in database
GPG key ID: 930BB00F3FCF30A4
3 changed files with 6 additions and 4 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -19,9 +19,11 @@ export async function run(): Promise<void> {
return Promise.reject(new Error(checkImages.reason));
}
const parsedCheckImages = JSON.parse(checkImages.output);
// this is to temporarily solve an issue with the case-sensitive of the property field name. i.e it is Names or names??
const nameKeyMixedCase = parsedCheckImages[0] && Object.keys(parsedCheckImages[0]).find(key => 'names' === key.toLowerCase());
const imagesFound = parsedCheckImages.
filter(image => image.names && image.names.find(name => name.includes(`${imageToPush}:${tag}`))).
map(image => image.names);
filter(image => image[nameKeyMixedCase] && image[nameKeyMixedCase].find(name => name.includes(`${imageToPush}:${tag}`))).
map(image => image[nameKeyMixedCase]);
if (imagesFound.length === 0) {
//check inside the docker daemon local storage
const pullFromDocker: CommandResult = await execute(podman, ['pull', `docker-daemon:${imageToPush}:${tag}`]);