Skip to content

Commit

Permalink
fix: limit versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed May 16, 2024
1 parent 9d8b421 commit 2567101
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lib/config/presets/internal/workarounds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ describe('config/presets/internal/workarounds', () => {
describe('bitnamiDockerImageVersioning', () => {
const versioning = presets.bitnamiDockerImageVersioning.packageRules![0]
.versioning as string;
const re = regEx(versioning.substring(6));
const versioningRe = regEx(versioning.substring(6));
const matchCurrentValue = presets.bitnamiDockerImageVersioning
.packageRules![0].matchCurrentValue as string;
const matchCurrentValueRe = regEx(
matchCurrentValue.substring(1, matchCurrentValue.length - 1),
);

it.each`
input | expected
Expand All @@ -18,8 +23,23 @@ describe('config/presets/internal/workarounds', () => {
${'1.24.0'} | ${true}
${'1.24.0-debian-12'} | ${true}
${'1.24.0-debian-12-r24'} | ${true}
`('matches("$input") == "$expected"', ({ input, expected }) => {
expect(re.test(input)).toEqual(expected);
`('versioning("$input") == "$expected"', ({ input, expected }) => {
expect(versioningRe.test(input)).toEqual(expected);
});

it.each`
input | expected
${'latest'} | ${false}
${'20'} | ${false}
${'20-debian'} | ${false}
${'20-debian-12'} | ${true}
${'1.24'} | ${false}
${'1.24-debian-12'} | ${true}
${'1.24.0'} | ${false}
${'1.24.0-debian-12'} | ${true}
${'1.24.0-debian-12-r24'} | ${true}
`('matchCurrentValue("$input") == "$expected"', ({ input, expected }) => {
expect(matchCurrentValueRe.test(input)).toEqual(expected);
});
});
});
2 changes: 2 additions & 0 deletions lib/config/presets/internal/workarounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const presets: Record<string, Preset> = {
description: 'Use custom regex versioning for bitnami images',
packageRules: [
{
matchCurrentValue:
'/^(?<major>\\d+)(?:\\.(?<minor>\\d+)(?:\\.(?<patch>\\d+))?)?-(?<compatibility>.+)-(?<build>\\d+)(?:-r(?<revision>\\d+))?$/',
matchDatasources: ['docker'],
matchPackagePrefixes: [
'bitnami/',
Expand Down

0 comments on commit 2567101

Please sign in to comment.