Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lib/modules/versioning): add Alpine (APK) and Chainguard tags versioning support #34357

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

lyoung-confluent
Copy link
Contributor

@lyoung-confluent lyoung-confluent commented Feb 20, 2025

Changes

Introduces a new versioning API alpine which can parse/compare the versioning schema produced by the Alpine Package Keeper (APK) used by Alpine Linux and Wolfi/Chainguard OS packages (not the OS version itself).

Additionally, it introduces a chainguard versioning API which extends the alpine versioning with support for the unique tags feature used by Chainguard (cgr.dev/...) Docker/OCI images.

Context

If you wish to use RenovateBot to upgrade the version of APKs, you can typically make it work using the semver or regex versioning schemes, but it won't handle more exotic versions correctly. At a high-level, APKs have a primary version (ex: 1.2.3) as well as an "epoch" or "revision" (ex: r1) which is typically incremented each time the package maintainer makes a change that differs from the upstream.

For example, the musl package currently has the version 1.2.5-r9. This means the upstream "tag" of musl will be v1.2.5, however the alpine maintainers have made 9 subsequent additional patches/metadata changes (in this case most recently to patch CVE-2025-26519). There are additional features/complexities supported by the versioning scheme such as release candidates (_rc<num>), proposed versions (_p<num>), and more.

This PR adds lib/modules/versioning/alpine which implements the VersioningApi interface allowing RenovateBot to correctly parse and compare these APK versions. It uses the same test data as the apk CLI, however a few more exotic test cases are commented out as they do not correctly parse/sort right now.

In addition to the alpine versioning API, a chainguard versioning API is introduced which extends the alpine versioning scheme. Chainguard maintains distroless (and low/no CVE) Docker/OCI images for many popular projects/images. As these images have become quite popular we would like to be able to maintain/upgrade the tags via RenovateBot.

While Chainguard creates/updates the standard latest tag for each image which can be used via the existing Docker datasource, typically you want to specify an exact version/tag of an image to deploy/use. Chainguard images are generally versioned/tagged using the version of the core package the image is based on/for, as an example: The cert-manager-webhook image will be tagged directly based on the version (including the revision/epoch) of the cert-manager APK package it contains.

However, because an image contains multiple packages, not just the main package we need an additional version field that will be incremented anytime a dependency like glibc is updated but the package remains on the same version. This is handled by Chainguard’s unique tags feature which adds a (always incrementing) date timestamp when the image was built in the format -%Y%m%d%H%M. So using the cert-manager-webhook image as an example, we could have the following tags:

  • 1.14.2-r0-202402261115: The first build of 1.14.2
  • 1.14.2-r0-202403060824: A dependency like glibc is updated
  • 1.14.2-r1-202403070335: A CVE in cert-manager is identified/patched by Chainguard
  • 1.14.2-r1-202403081212: A dependency like busybox is updated

The lib/modules/versioning/chainguard API adds support for parsing/comparing this date suffix, as well as logic to avoid mixing -dev tags (contain busybox and other developer tools) with non -dev tags.

Documentation

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@lyoung-confluent lyoung-confluent changed the title feat(lib/modules/versioning): add Alpine and Chainguard (APK) versioning support feat(lib/modules/versioning): add Alpine (APK) and Chainguard tags versioning support Feb 20, 2025
@MindTooth
Copy link
Contributor

Regarding Chainguard, it’s important to preface that the unique tags are only for the commercial offerings (requires an account). Free only usually have latest or latest-dev.

return -1;
}

// TODO: Implement correct comparison of suffix
Copy link
Collaborator

Choose a reason for hiding this comment

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

TODO before merging?


describe('modules/versioning/alpine/index', () => {
// https://gitlab.alpinelinux.org/alpine/apk-tools/-/blob/master/test/version.data
// The following rows were removed as they are failing tests right now:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it ok if these remain wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In practice these variants are quite rare, I believe they are failing because I didn't implement the suffix comparisons (the TODO line above). How would you prefer I proceed? I could attempt to implement the rarely used versions and get to 100% coverage (might take some time before I can get to this), or I could convert the above TODO to an open issue and work on it as a follow-up

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally this file would include isVersion() and equals() tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants