in src/commands/image/reingest.ts [37:74]
async run() {
const { args, flags } = await this.parse(ImageReingest)
const imageId: string = args.id
const http = this.http!
const profile = this.profile!
const dryRun = flags.dryRun
const compare = flags.compare
const force = Boolean(flags.force)
const serviceDiscovery = await new ServiceDiscovery(http, profile.mediaApiHost).discover()
const adminTools = serviceDiscovery.getLink('admin-tools')
if (!adminTools) {
this.error(`Could not find the admin-tools service. Is it listed at ${profile.mediaApiHost}?`, { exit: 1 })
}
const imageResponse = await this.fetchImage(imageId)
if (this.imageExists(imageResponse) && !force) {
this.error(`Cannot reingest - there is already an image with id ${imageId} in the Grid. Add --force to overwrite it.`, { exit: 1 })
}
const imageToReingest = await this.fetchProjection(imageId, adminTools.href, !dryRun)
if (dryRun || compare) {
await this.printProjection(imageToReingest, Boolean(compare))
} else {
this.log(`Reingestion for image with id ${imageId} sent to queue.\n`)
try {
await this.pollForImage(imageId)
this.log('\nImage successfully reingested.')
} catch (error) {
this.error((error as Error)?.message)
}
}
}