Skip to content

[Feature request] Push branch/refspec templating to enable PR-driven update flow in monorepos #938

@crabique

Description

@crabique

Hello!

I want to propose a change that would be super useful for people using a single ImageUpdateAutomation for updating image references in monorepos.

At the moment, the ImageUpdateAutomation resource supports pushing image updates to a branch that is different to the checkout one, this could be used to implement a flow where a pull request is automatically opened for such updates.

Unfortunately, since the push .branch/.refspec is hardcoded in the resource itself, all updates done by a single ImageUpdateAutomation will all be pushed to the same branch. This makes it awkward to use with monorepos: first PR is opened as intended, but if it's not merged before a new image update happens, the new update will be pushed to the same branch, thus adding it to the first PR (loss of granularity), while no PR will be created for the newer change.

I am proposing an addition of a bool key like .spec.git.push.useTemplates that would enable go-template rendering in .spec.git.push.branch or .spec.git.push.refspec: this keeps the backwards compatibility and would be false by default.

Enabling this feature would allow users to implement at least a per-ImagePolicy updates that can be atomically turned into PRs.

Example:

spec:
  git:
    push:
      # all updates done by a single ImagePolicy will be pushed to this branch
      # automatic PR creation on Git server's end can be setup based on the 'image-bump/' prefix
      branch: 'image-bump/{{ .PolicyObject }}'
      useTemplates: true

This .PolicyObject variable is essentially already available in commit message templating as .Changed.Changes[].Setter.

Alternatively, the template could support other useful variables to allow for a smarter management/grouping of such changes:

  • an imageGroup: label value of ImagePolicies—would allow to open a PR for a group of related images all in one place
  • SemVer mask (e.g. compare current version to the new, and reduce it to v1.2.X)—similar to how Renovate does it—makes it clear just from the branch name whether it's a patch, minor or a major update; based on this, automatic merge rules can be applied conditionally
  • raw old and new version values (.Changed.Changes[].{Old,New}Value)—similar to how it's implemented in tools like ArgoCD image updater
  • I could think of more (digests and so on), but even what's already listed above would cover vast majority of use-cases

Hopefully, this proposal makes sense to you, but I will be glad to answer any questions. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions