Last active
June 30, 2022 10:59
-
-
Save brurucy/51ea9e4c7025064f5bb3c9d88d59e813 to your computer and use it in GitHub Desktop.
dora-snippet-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function (config) { | |
try { | |
// Negative Lookahead on comments line | |
const key = `^(?!#)${config.param}`; | |
// Get Base image from Dockerfile.CI | |
const dockerfileCIResults = await findStringByKey(config, key); | |
const dockerFileConfig = { path: 'Dockerfile', param: config.param }; | |
const dockerfileResults = await findStringByKey(dockerFileConfig, key); | |
if (dockerfileCIResults.length > 0) { | |
// Compare the last FROM ocurrency for both files | |
const baseImageCI = dockerfileCIResults.slice(-1)[0].line.value; | |
if (dockerfileResults.length > 0) { | |
// Image found in both files | |
const baseDevImage = dockerfileResults.slice(-1)[0].line.value.trim(); | |
if (baseImageCI !== baseDevImage && `${baseImageCI}-dev` !== baseDevImage && !isGoService()) { | |
await reporter.report(config, dockerfileCIResults.slice(-1)[0].line); | |
} | |
} else { | |
// Image found only in Dockerfile.CI | |
await reporter.report(config, dockerfileCIResults.slice(-1)[0].line); | |
} | |
} else { | |
if (dockerfileResults.length > 0) { | |
// Image found only in Dockerfile | |
await reporter.report(config, dockerfileResults.slice(-1)[0].line); | |
} | |
} | |
} catch (err) { | |
const error = `Error message: ${err}`; | |
await reporter.reportError(error, config); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment