Skip to content

feat(docs): add section about bumping Cluster imageName using renovate#330

Merged
gbartolini merged 5 commits into
cloudnative-pg:mainfrom
DerRockWolf:renovate-config
May 19, 2026
Merged

feat(docs): add section about bumping Cluster imageName using renovate#330
gbartolini merged 5 commits into
cloudnative-pg:mainfrom
DerRockWolf:renovate-config

Conversation

@DerRockWolf
Copy link
Copy Markdown
Contributor

@DerRockWolf DerRockWolf commented Sep 27, 2025

This regex manager example can be used by users of renovate that want to also automate updates of their CNPG clusters.

Resolves #257

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. documentation Improvements or additions to documentation labels Sep 27, 2025
@acuntex
Copy link
Copy Markdown

acuntex commented Sep 29, 2025

I've been running this against CNPG tags and hit two practical issues with the current snippet:

  1. Digest is mandatory in the regex
    The pattern requires @sha256:.... If a file has only a tag (no digest), Renovate can't extract -> won't open a PR. Making the digest optional lets Renovate both introduce a digest and refresh it later. The README's example currently requires the digest.

  2. File pattern + robustness

  • Consider matching both .yaml and .yml (and optional .j2), not only .yaml.
  • It's safer if the tag capture stops before @ (digest) and before inline comments #.

Also, it helps to add a replaceStringTemplate that writes back the new tag and (optional) digest.

Proposed doc snippet (drop-in):

{
  customManagers: [
    {
      // CloudNativePG Cluster imageName
      customType: "regex",
      description: ["Process CloudnativePG Postgresql version"],
      managerFilePatterns: ["/\\.ya?ml(?:\\.j2)?$/"],
      matchStrings: [
        "imageName:\\s*(?<depName>[^:\\s#]+):(?<currentValue>[^@\\s#]+)(?:@(?<currentDigest>sha256:[A-Fa-f0-9]{64}))?"
      ],
      datasourceTemplate: "docker",
      versioningTemplate: "regex:^(?<major>\\d+)\\.(?<minor>\\d+)-(?<patch>\\d+)(?:-(?<compatibility>\\S+))?$",
      replaceStringTemplate: "imageName: {{depName}}:{{newValue}}{{#if newDigest}}@{{newDigest}}{{/if}}"
    }
  ]
}

Why this is safer:

  • Digest is optional and strictly validated (sha256:[A-Fa-f0-9]{64}), so extraction works before/after pinning.
  • currentValue stops at @ and #, so the digest and comments aren't swallowed.
  • managerFilePatterns covers .yaml/.yml and templated .j2.
  • replaceStringTemplate avoids Renovate writing only the tag and dropping the digest by accident.

@DerRockWolf
Copy link
Copy Markdown
Contributor Author

@acuntex although your answer smells quite a bit AI (correct me if I'm wrong) I'm still going to address a few points.

Firstly, this PR just adds an example renovate manager, so if you need something more specific feel free to adjust it in your config.

The official file extension is .yaml. If you have any other extensions in use, like suggested by your template example, please adapt the config for your own setup. .j2 isn't the only templating "format" out there, so adding just one makes not much sense.

I adapted the regex so that the digest is optional.

By the way, if you don't want to do the entire work on your own at least check that what the LLM spat out is correct. replaceStringTemplate doesn't exist anymore / was renamed.

@acuntex
Copy link
Copy Markdown

acuntex commented Oct 5, 2025

@DerRockWolf I grabbed an older custom manager from my own repo as inspiration and shared my notes here to improve the user experience for folks configuring Renovate with CNPG.
If my comment came across as criticism, that wasn't my intent. Sorry about that. I appreciate you making the digest optional and pointing out the renamed key.
I value the project and want to contribute constructively. Tone matters for motivating contributors. My goal is collaboration, not contention.

Comment thread README.md Outdated
@mnencia mnencia force-pushed the renovate-config branch from b27b577 to 47d18a2 Compare May 15, 2026 10:58
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels May 17, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 17, 2026
@mnencia mnencia force-pushed the renovate-config branch from ff6a4ce to d975fc9 Compare May 17, 2026 17:43
DerRockWolf and others added 5 commits May 19, 2026 15:00
…ovate

Signed-off-by: RockWolf <git@rockwolf.eu>
Signed-off-by: RockWolf <git@rockwolf.eu>
Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
Signed-off-by: DerRockWolf <50499906+DerRockWolf@users.noreply.github.com>
Renovate replaces the full regex match with the rendered template, so
the original template stripped the `imageName: ghcr.io/...:` prefix
and produced invalid YAML. Including the prefix and `depName` in the
template fixes the replacement while preserving the ability to pin a
digest when one is not already present.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
Route PostgreSQL major updates through the dependency dashboard for
human approval, and anchor the digest match to exactly 64 hex
characters so malformed digests are no longer captured.

Clarify the trailing prose: the `compatibility` segment pins image
flavour and Debian base (not abstract "compatibility"), and switching
the Debian base is a manual operation because of PostgreSQL
locale-data implications. Note that the example uses JSON5 syntax and
suggest narrowing `managerFilePatterns` when the user repository
contains unrelated YAML.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
@gbartolini gbartolini merged commit ae35214 into cloudnative-pg:main May 19, 2026
1 of 4 checks passed
@DerRockWolf DerRockWolf deleted the renovate-config branch May 19, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Renovate config for standard images

4 participants