-
-
Notifications
You must be signed in to change notification settings - Fork 113
Fix usage of versionfilter regex kind in autodiscovery plugins #7223
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
Conversation
|
Thanks for the pull request. |
Signed-off-by: Olblak <me@olblak.com>
|
Thanks for the pull request, while reviewing, I noticed some missing part from I didn't test everything |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request fixes a critical template rendering bug in autodiscovery plugins where the SourceVersionFilterRegex field was being referenced in templates without being properly defined in the template context, causing template execution errors when using versionfilter with kind: regex.
The PR implements two key changes:
- Removes the incorrect
"regex"kind from conditional checks in manifest templates (only"regex/semver"and"regex/time"should render the regex field) - Adds the
VersionFilterRegexparameter to template data structures across all autodiscovery plugins
Reviewed changes
Copilot reviewed 45 out of 45 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/plugins/autodiscovery/updatecli/policies.go | Adds SourceVersionFilterRegex field initialization and population in template data |
| pkg/plugins/autodiscovery/updatecli/manifestTemplate.go | Removes "regex" from conditional check for regex field rendering |
| pkg/plugins/autodiscovery/terragrunt/modules.go | Adds VersionFilterRegex field to template parameters |
| pkg/plugins/autodiscovery/terragrunt/manifest_template.go | Adds conditional rendering of regex field for regex/semver and regex/time kinds |
| pkg/plugins/autodiscovery/terraform/providers.go | Adds VersionFilterRegex field to template parameters |
| pkg/plugins/autodiscovery/terraform/manifest_template.go | Adds conditional rendering of regex field for regex/semver and regex/time kinds |
| pkg/plugins/autodiscovery/precommit/manifestTemplate.go | Removes "regex" from conditional checks for regex field rendering (2 occurrences) |
| pkg/plugins/autodiscovery/precommit/dependency.go | Adds versionRegex initialization and SourceVersionFilterRegex to template data |
| pkg/plugins/autodiscovery/npm/manifestTemplate.go | Removes "regex" from conditional check and adds SourceVersionFilterRegex field |
| pkg/plugins/autodiscovery/npm/dependency.go | Adds sourceVersionFilterRegex initialization and population in multiple code paths |
| pkg/plugins/autodiscovery/nomad/manifestTemplate.go | Removes "regex" from conditional checks for regex field rendering (2 occurrences) |
| pkg/plugins/autodiscovery/nomad/dockerDriver.go | Adds versionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/maven/manifestTemplate.go | Removes "regex" from conditional check for regex field rendering |
| pkg/plugins/autodiscovery/maven/dependencyParentPom.go | Adds sourceVersionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/maven/dependency.go | Adds sourceVersionFilterRegex field to struct (missing conditional assignment - see bug comment) |
| pkg/plugins/autodiscovery/kubernetes/manifestTemplate.go | Removes "regex" from conditional checks for regex field rendering (2 occurrences) |
| pkg/plugins/autodiscovery/kubernetes/containers.go | Adds versionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/ko/manifestTemplate.go | Removes "regex" from conditional checks for regex field rendering (2 occurrences) |
| pkg/plugins/autodiscovery/ko/containers.go | Adds versionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/helmfile/releases.go | Adds sourceVersionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/helmfile/manifestTemplate.go | Removes "regex" from conditional check for regex field rendering |
| pkg/plugins/autodiscovery/helm/dependencyManifest.go | Removes "regex" from conditional check for regex field rendering |
| pkg/plugins/autodiscovery/helm/dependencies.go | Adds sourceVersionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/helm/containerManifest.go | Removes "regex" from conditional check and adds regex field rendering for digest template |
| pkg/plugins/autodiscovery/helm/container.go | Adds versionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/golang/manifestTemplate.go | Removes "regex" from conditional checks for regex field rendering (3 occurrences) |
| pkg/plugins/autodiscovery/golang/dependency.go | Updates function signatures and adds versionFilterRegex to all module manifest functions (parameter order issue - see bug comment) |
| pkg/plugins/autodiscovery/githubaction/workflowGHAManifest.go | Adds versionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/githubaction/workflowDockerManifest.go | Adds versionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/githubaction/templateGHAGitea.go | Adds conditional rendering of regex field for regex/semver and regex/time kinds (3 occurrences) |
| pkg/plugins/autodiscovery/githubaction/templateGHAGitHub.go | Adds conditional rendering of regex field for regex/semver and regex/time kinds (3 occurrences) |
| pkg/plugins/autodiscovery/flux/ociRepositoryManifests.go | Adds versionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/flux/ociRepositoryManifestTemplate.go | Removes "regex" from conditional checks for regex field rendering (2 occurrences) |
| pkg/plugins/autodiscovery/flux/main.go | Adds defaultVersionFilterRegex constant |
| pkg/plugins/autodiscovery/flux/helmreleaseManifests.go | Adds sourceVersionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/flux/helmreleaseManifestTemplate.go | Removes "regex" from conditional check for regex field rendering |
| pkg/plugins/autodiscovery/fleet/manifestTemplate.go | Removes "regex" from conditional check for regex field rendering |
| pkg/plugins/autodiscovery/fleet/dependencies.go | Adds sourceVersionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/dockerfile/manifestTemplate.go | Removes "regex" from conditional checks for regex field rendering (2 occurrences) |
| pkg/plugins/autodiscovery/dockercompose/manifestTemplate.go | Removes "regex" from conditional checks for regex field rendering (2 occurrences) |
| pkg/plugins/autodiscovery/dockercompose/compose.go | Adds versionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/cargo/dependencyManifest.go | Adds conditional rendering of regex field for regex/semver and regex/time kinds |
| pkg/plugins/autodiscovery/cargo/dependencies.go | Adds sourceVersionFilterRegex initialization and population in template data |
| pkg/plugins/autodiscovery/argocd/manifestTemplate.go | Removes "regex" from conditional check for regex field rendering |
| pkg/plugins/autodiscovery/argocd/application.go | Adds sourceVersionFilterRegex initialization and population in template data |
Comments suppressed due to low confidence (1)
pkg/plugins/autodiscovery/maven/dependency.go:115
- The sourceVersionFilterRegex should be set inside this conditional block, similar to how it's done in dependencyParentPom.go. Without this, when a custom VersionFilter is specified, the regex value won't be updated and will remain at its default value from line 107, potentially causing incorrect filtering behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Olblak <me@olblak.com>
…tecli into fix-versionfilter-regex
|
Copilot is right about:
I'll push an addition to this file. |
|
Thanks for the quick fix. |
loispostula
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch and good fix, thanks a lot
I'm trying to use updatecli on a maven project to update only its parent version.
The parent dependency is released in two formats, a three digits one and a two digits one.
I want updatecli to update the parent version with the two digits format, so I used the regex versionfilter kind:
During my tests of this configuration I was not able to get an update difference and notice this error in debug logs:
It happens only on 0.112.0, everything seems to work on 0.111.0.
I had a look to the maven autodiscovery plugin that causes this error and noticed that the template would render the regex field in this context:
According to the maven autodiscoverry plugin documentation https://www.updatecli.io/docs/plugins/autodiscovery/maven/, the regex field should be set when
regex/semverandregex/timeare used.The current code includes the regex field with the
regexkind, the first commit of this PR fixes that to respect the documentation for all autodiscovery plugins.The second commit is about adding the link between the autodiscovery plugin configuration and the templating by giving versionFilterRegex parameters to template rendering.
Additional Information
Potential improvement
There're default in some autodiscovery plugins that I set Regex to
*which shouldn't be a problem for most usage as it is printed only forregex/semverandregex/timeKind. But there's might be room for improvements.