From 2c70a5d2232ad5c9a7d1623ce527b1d8f4458166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= <github@jkroepke.de> Date: Mon, 16 Jan 2023 11:14:13 +0100 Subject: [PATCH] feat(presets/regex): Add preset for appVersion in helm charts (#19371) Co-authored-by: Rhys Arkins <rhys@arkins.net> Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de> --- lib/config/presets/internal/regex-managers.ts | 12 +++++++ lib/modules/manager/regex/readme.md | 34 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/lib/config/presets/internal/regex-managers.ts b/lib/config/presets/internal/regex-managers.ts index 55494a3f95..fc06068f94 100644 --- a/lib/config/presets/internal/regex-managers.ts +++ b/lib/config/presets/internal/regex-managers.ts @@ -26,4 +26,16 @@ export const presets: Record<string, Preset> = { }, ], }, + helmChartYamlAppVersions: { + description: 'Update `appVersion` value in Helm chart Chart.yaml.', + regexManagers: [ + { + datasourceTemplate: 'docker', + fileMatch: ['(^|/)Chart\\.yaml$'], + matchStrings: [ + '#\\s*renovate: image=(?<depName>.*?)\\s+appVersion:\\s*["\']?(?<currentValue>[\\w+\\.\\-]*)', + ], + }, + ], + }, }; diff --git a/lib/modules/manager/regex/readme.md b/lib/modules/manager/regex/readme.md index 3d267bb9e7..a4a0ab6185 100644 --- a/lib/modules/manager/regex/readme.md +++ b/lib/modules/manager/regex/readme.md @@ -128,9 +128,41 @@ This is because Handlebars escapes special characters with double braces (by def By adding `renovate: datasource=` and `depName=` comments to the `Dockerfile` you only need _one_ `regexManager` instead of _four_. The `Dockerfile` is documented better as well. -The syntax in the example is arbitrary and you can set your own syntax. +The syntax in the example is arbitrary, and you can set your own syntax. If you do, update your `matchStrings` regex! +You can use simple versions of such comments to increase readability. + +For example the `appVersion` property in a `Chart.yaml` of a Helm chart is always referenced to an Docker image. +In such scenarios, some values can be hard-coded. +For example: + +```yaml +apiVersion: v2 +name: amazon-eks-pod-identity-webhook +description: A Kubernetes webhook for pods that need AWS IAM access +version: 1.0.3 +type: application +# renovate: image=amazon/amazon-eks-pod-identity-webhook +appVersion: 'v0.4.0' +``` + +Using the `regexManagers` below, Renovate looks for available Docker tags of the image `amazon/amazon-eks-pod-identity-webhook`. + +```json +{ + "regexManagers": [ + { + "datasourceTemplate": "docker", + "fileMatch": ["(^|/)Chart\\.yaml$"], + "matchStrings": [ + "#\\s?renovate: image=(?<depName>.*?)\\s?appVersion:\\s?\\\"?(?<currentValue>[\\w+\\.\\-]*)\"" + ] + } + ] +} +``` + ### Using regexManager to update the dependency name in addition to version #### Updating `gitlab-ci include` dep names -- GitLab