Skip to content

Conversation

DerRockWolf
Copy link

@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

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
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

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.

}
```

Renovate will never change the `compatibility` part of the tag! So bumping from e.g., `trixie` to the next debian release must be done manually.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the part about bumping 'trixie' to something else. The procedure to change the OS of the image is not straightforward and requires careful execution; simply changing the image is not enough.

Suggested change
Renovate will never change the `compatibility` part of the tag! So bumping from e.g., `trixie` to the next debian release must be done manually.
Renovate will never change the `compatibility` part of the tag, ensuring that the upgraded images will remain compatible.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on that a bit? I thought that at some point after a new Debian release came out you will also provide images for this new version. What else would I as a user need to adapt in order to use the new OS?

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 size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Renovate config for standard images

3 participants