Skip to content

Commit

Permalink
fix(dockerfile): loosen default dockerfile manager filematch (#15583)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitfool committed May 15, 2022
1 parent 918ef59 commit 5043379
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/usage/configuration-options.md
Expand Up @@ -767,8 +767,8 @@ At other times, the possible files is too vague for Renovate to have any default
For default, Kubernetes manifests can exist in any `*.yaml` file and we don't want Renovate to parse every single YAML file in every repository just in case some of them have a Kubernetes manifest, so Renovate's default `fileMatch` for manager `kubernetes` is actually empty (`[]`) and needs the user to tell Renovate what directories/files to look in.

Finally, there are cases where Renovate's default `fileMatch` is good, but you may be using file patterns that a bot couldn't possibly guess about.
For example, Renovate's default `fileMatch` for `Dockerfile` is `['(^|/|\\.)Dockerfile$', '(^|/)Dockerfile\\.[^/]*$']`.
This will catch files like `backend/Dockerfile`, `prefix.Dockerfile` or `Dockerfile.suffix`, but it will miss files like `ACTUALLY_A_DOCKERFILE.template`.
For example, Renovate's default `fileMatch` for `Dockerfile` is `['(^|/|\\.)Dockerfile$', '(^|/)Dockerfile[^/]*$']`.
This will catch files like `backend/Dockerfile`, `prefix.Dockerfile` or `Dockerfile-suffix`, but it will miss files like `ACTUALLY_A_DOCKERFILE.template`.
Because `fileMatch` is mergeable, you don't need to duplicate the defaults and could just add the missing file like this:

```json
Expand Down
4 changes: 2 additions & 2 deletions lib/config/__snapshots__/migration.spec.ts.snap
Expand Up @@ -57,7 +57,7 @@ Object {
Object {
"fileMatch": Array [
"(^|/|\\\\.)Dockerfile$",
"(^|/)Dockerfile\\\\.[^/]*$",
"(^|/)Dockerfile[^/]*$",
],
"matchStrings": Array [
"# renovate: datasource=(?<datasource>[a-z-]+?) depName=(?<depName>[^\\\\s]+?)(?: lookupName=(?<packageName>[^\\\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?\\\\s(?:ENV|ARG) .+?_VERSION=\\"?(?<currentValue>.+?)\\"?\\\\s",
Expand All @@ -66,7 +66,7 @@ Object {
Object {
"fileMatch": Array [
"(^|/|\\\\.)Dockerfile$",
"(^|/)Dockerfile\\\\.[^/]*$",
"(^|/)Dockerfile[^/]*$",
],
"matchStrings": Array [
"# renovate: datasource=(?<datasource>[a-z-]+?) depName=(?<depName>[^\\\\s]+?)(?: lookupName=(?<holder>[^\\\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?\\\\s(?:ENV|ARG) .+?_VERSION=\\"?(?<currentValue>.+?)\\"?\\\\s",
Expand Down
4 changes: 2 additions & 2 deletions lib/config/migration.spec.ts
Expand Up @@ -627,13 +627,13 @@ describe('config/migration', () => {
const config: RenovateConfig = {
regexManagers: [
{
fileMatch: ['(^|/|\\.)Dockerfile$', '(^|/)Dockerfile\\.[^/]*$'],
fileMatch: ['(^|/|\\.)Dockerfile$', '(^|/)Dockerfile[^/]*$'],
matchStrings: [
'# renovate: datasource=(?<datasource>[a-z-]+?) depName=(?<depName>[^\\s]+?)(?: lookupName=(?<lookupName>[^\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?\\s(?:ENV|ARG) .+?_VERSION="?(?<currentValue>.+?)"?\\s',
],
},
{
fileMatch: ['(^|/|\\.)Dockerfile$', '(^|/)Dockerfile\\.[^/]*$'],
fileMatch: ['(^|/|\\.)Dockerfile$', '(^|/)Dockerfile[^/]*$'],
matchStrings: [
'# renovate: datasource=(?<datasource>[a-z-]+?) depName=(?<depName>[^\\s]+?)(?: lookupName=(?<holder>[^\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?\\s(?:ENV|ARG) .+?_VERSION="?(?<currentValue>.+?)"?\\s',
],
Expand Down
2 changes: 1 addition & 1 deletion lib/config/presets/internal/regex-managers.ts
Expand Up @@ -5,7 +5,7 @@ export const presets: Record<string, Preset> = {
description: 'Update _VERSION variables in Dockerfiles',
regexManagers: [
{
fileMatch: ['(^|/|\\.)Dockerfile$', '(^|/)Dockerfile\\.[^/]*$'],
fileMatch: ['(^|/|\\.)Dockerfile$', '(^|/)Dockerfile[^/]*$'],
matchStrings: [
'# renovate: datasource=(?<datasource>[a-z-]+?) depName=(?<depName>[^\\s]+?)(?: (lookupName|packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?\\s(?:ENV|ARG) .+?_VERSION="?(?<currentValue>.+?)"?\\s',
],
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/dockerfile/index.ts
Expand Up @@ -7,7 +7,7 @@ const language = ProgrammingLanguage.Docker;
export { extractPackageFile, language };

export const defaultConfig = {
fileMatch: ['(^|/|\\.)Dockerfile$', '(^|/)Dockerfile\\.[^/]*$'],
fileMatch: ['(^|/|\\.)Dockerfile$', '(^|/)Dockerfile[^/]*$'],
};

export const supportedDatasources = [DockerDatasource.id];

0 comments on commit 5043379

Please sign in to comment.