Skip to content

Commit

Permalink
feat(presets/workarounds): add bitnami docker versioning (#29112)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed May 16, 2024
1 parent 20716b0 commit 66de046
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/config/presets/internal/workarounds.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { regEx } from '../../../util/regex';
import { presets } from './workarounds';

describe('config/presets/internal/workarounds', () => {
describe('bitnamiDockerImageVersioning', () => {
const versioning = presets.bitnamiDockerImageVersioning.packageRules![0]
.versioning as string;
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
${'latest'} | ${false}
${'20'} | ${true}
${'20-debian'} | ${false}
${'20-debian-12'} | ${true}
${'1.24'} | ${true}
${'1.24-debian-12'} | ${true}
${'1.24.0'} | ${true}
${'1.24.0-debian-12'} | ${true}
${'1.24.0-debian-12-r24'} | ${true}
`('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);
});
});
});
18 changes: 18 additions & 0 deletions lib/config/presets/internal/workarounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,27 @@ export const presets: Record<string, Preset> = {
'workarounds:disableEclipseLifecycleMapping',
'workarounds:disableMavenParentRoot',
'workarounds:containerbase',
'workarounds:bitnamiDockerImageVersioning',
],
ignoreDeps: [], // Hack to improve onboarding PR description
},
bitnamiDockerImageVersioning: {
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/',
'docker.io/bitnami/',
'gcr.io/bitnami-containers/',
],
versioning:
'regex:^(?<major>\\d+)(?:\\.(?<minor>\\d+)(?:\\.(?<patch>\\d+))?)?(:?-(?<compatibility>.+)-(?<build>\\d+)(?:-r(?<revision>\\d+))?)?$',
},
],
},
containerbase: {
description: 'Add some containerbase overrides.',
packageRules: [
Expand Down

0 comments on commit 66de046

Please sign in to comment.