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

Feature Request: Allow versionfilter on target #1203

Closed
olblak opened this issue Mar 6, 2023 · 4 comments
Closed

Feature Request: Allow versionfilter on target #1203

olblak opened this issue Mar 6, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@olblak
Copy link
Member

olblak commented Mar 6, 2023

Is your feature request related to a problem?

I would like to have different update strategies based on the type of version bump.

Solution you'd like

If the updatecli version bump is:
Other situation would be to ignore patch version update

  • A patch version change, then I would like to open a GitHub pullrequest with the automerge flag enabled
  • A minor version change, then I would like to open a Github pullrequest with
  • A major version change, then I would like to open a GitHub pullrequest with a specific label
sources:
  updatecli:
    kind: githubrelease
    spec: 
      owner: updatecli
      repository: updatecli
      token: xxx
targets:
  updatecli:
    kind: yaml
    spec:
      file: action.yaml
      key: version
    versionfilter:
      kind: semver
      spec:
        minor: true
        patch: true

Alternatives you've considered

Condition

I considered adding a new condition of type semver but we have the two following constraint:
.1 Between a source and a target, the information could be transformed using the "transformers"
.2 We only know at the target stage the version used

Source

I considered handling this at the source level with the current versionfilter implementation, but we don't know yet what the target value would be.

Pipeline refactoring

I considered changing the core pipeline to go from
.1 Get sources
.2 Check condition
.3 Update target

to
.1 Get target value
.2 Get source
.3 Check condition
.4 Update target

But I don't think, the time spent of this type of refactoring is worthwhile

Anything else?

No response

@olblak olblak added the enhancement New feature or request label Mar 6, 2023
@dduportal
Copy link
Contributor

Might be a dumb idea but have you considered using the template engine for these use cases?

yaml is not really a good tool when dealing with control structures such as conditions.

With templating, extended with some keywords, that could be interesting:

automerge: {{ source « mavenVersion » | isSemVerPatchChanged }}

@olblak
Copy link
Member Author

olblak commented Mar 9, 2023

Thanks for the feedback and yes I did.
The problem with the templating is that it happens before Updatecli execute any action of type source,condition, or target.
The resources are not aware of template information.

With the sprig template integration, we could already write manifest in a way that would run such validation but that would be hard to express

-> https://masterminds.github.io/sprig/semver.html

@olblak
Copy link
Member Author

olblak commented Mar 30, 2023

After additional thought, I don't think I'll add more fields to versionfilter, instead I will reuse the existing one such as

targets:
  updatecli:
    kind: yaml
    spec:
      file: action.yaml
      key: version
    versionfilter:
      kind: semver
      pattern: "patch"

In the context of a target a pattern of kind semver would allow one

  • major
  • minor
  • patch
  • prerelease
  • any valid semver constraint such as "< 2.0.0"

In the context of target a pattern of kind semver would allow any regular expression

If the versionfilter pattern do not match then the target is not updated and return a failure.

The purpose of this feature is to be able to have different type of update pipeline such as
patch only update -> automerge true
minor only update -> automerge false

@olblak
Copy link
Member Author

olblak commented Apr 21, 2023

I don't think anymore it makes sense to have the versionfilter on the target.
It's the role of the source to retrieve the right value, and the role of the condition to abort the pipeline if needed.

In the context of the autodiscovery I experimented on the Golang plugin the ability to override the default versionfilter.
It works well and does exactly what I am looking for.

Therefor I am closing this issue as it is now duplicated with #977

@olblak olblak closed this as completed Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

2 participants