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

[source][condition] Allow to filter Github Release per release type #969

Merged
merged 18 commits into from
Nov 11, 2022

Conversation

olblak
Copy link
Member

@olblak olblak commented Nov 7, 2022

Allow to filter GitHub Release per release type (draft,prelease,release,latest)
I am also adding the missing Github Release condition

conditions:
  default:
    name: Default Get Latest Release
    kind: githubrelease
    sourceid: default
    spec:
      owner: updatecli
      repository: updatecli
      typefilter:
          # draft: true
          # prerelease: true
          # release: true
          latest: true
      token: '{{ requiredEnv "UPDATECLI_GITHUB_TOKEN" }}'
      username: '{{ requiredEnv "UPDATECLI_GITHUB_ACTOR" }}'

Test

To test this pull request, you can run the following commands:

go build -o bin/updatecli
./bin/updatecli diff --config e2e/updatecli.d/success.d/githubRelease.yaml --debug 

Additional Information

Tradeoff

For historical reason #196
The Github Release fallback to searching Git Tag if no GitHub release could be found.
This behavior is incompatible with filter release by tag as it would return the latest git tag if no release could be found matching release type.

To not introduce breaking change, I am introducing the parameter disabletagsearch which can be set to true to enforce the new behavior. This parameter will be remove in a futur release once we are ready to remove the old behavior.

Potential improvement

Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak added enhancement New feature or request resource-githubRelease Resource of kind GitHub Release labels Nov 7, 2022
@olblak olblak marked this pull request as draft November 7, 2022 19:05
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak
Copy link
Member Author

olblak commented Nov 8, 2022

After thinking more about this PR.
I'll change a little bit the approach.
I am gonna remove the parameter disabletagsearch

We keep the current deprecate behavior only if no release type have been specified and we couldn't find a release.
All the other scenario just ignore gittag

olblak and others added 3 commits November 8, 2022 13:02
refactor a bit

Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak marked this pull request as ready for review November 8, 2022 12:28
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak
Copy link
Member Author

olblak commented Nov 9, 2022

As part @lemeurherve @dduportal feedback, I revert the last commit and changed the key from type to typefilter

olblak and others added 3 commits November 9, 2022 17:36
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak merged commit 316c1ff into updatecli:main Nov 11, 2022
@dduportal
Copy link
Contributor

A quick comment to confirm that this PR introduces a regression to the GH releases filtering when using a regexp (at least) filter.

The manifest https://github.com/jenkinsci/docker-agent/blob/master/updatecli/updatecli.d/jdk11.yaml allows to reproduce the issue:

I'm going to run a debuger to understand why is the regression.

@dduportal
Copy link
Contributor

Ok, got the issue: it seems that the default values when typeFilter is not specified are incorrect: the "Latest" field is set to false by default but it should not. Incoming PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request resource-githubRelease Resource of kind GitHub Release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants