in src/utilities/manifestUpdateUtils.ts [119:146]
export function substituteImageNameInSpecFile(
spec: string,
imageName: string,
imageNameWithNewTag: string
) {
if (spec.indexOf(imageName) < 0) return spec
return spec.split('\n').reduce((acc, line) => {
const imageKeyword = line.match(/^ *-? *image:/)
if (imageKeyword) {
let [currentImageName] = line
.substring(imageKeyword[0].length) // consume the line from keyword onwards
.trim()
.replace(/[',"]/g, '') // replace allowed quotes with nothing
.split(':')
if (currentImageName?.indexOf(' ') > 0) {
currentImageName = currentImageName.split(' ')[0] // remove comments
}
if (currentImageName === imageName) {
return acc + `${imageKeyword[0]} ${imageNameWithNewTag}\n`
}
}
return acc + line + '\n'
}, '')
}