diff --git a/content/en/docs/plugins/_versionFilter.adoc b/content/en/docs/plugins/_versionFilter.adoc index 2c5fdf89..4c2db022 100644 --- a/content/en/docs/plugins/_versionFilter.adoc +++ b/content/en/docs/plugins/_versionFilter.adoc @@ -57,6 +57,9 @@ If `versionFilter.kind` is set to `regex` then we can use `versionFilter.pattern return the newest version returned from a resource matching the regex If no versionFilter.pattern is provided then it uses '.*' which return the newest version +`versionFilter.replaceall` can optionally be used to transform version strings before the regex is applied. +It accepts a `pattern` (regex) and a `replacement` string, similar to a find-and-replace operation. + ``` sources: kubectl: @@ -74,6 +77,28 @@ sources: ``` => Return the newest kubectl version matching pattern "kubernetes-1.(\\d*).(\\d*)$" and remove "kubernetes-" from it +===== Example with replaceall + +Some projects use version tags that are not directly compatible with the regex pattern. For example, curl uses tags like +`curl-8_11_1` where underscores separate version components. +The `replaceall` option can be used to normalize these tags before applying the regex. + +```yaml +sources: + curl: + kind: githubRelease + spec: + owner: "curl" + repository: "curl" + versionFilter: + kind: regex + regex: 'curl-(\d+\.\d+\.\d+)' + replaceall: + pattern: "_" + replacement: "." +``` +=> The `replaceall` converts `curl-8_11_1` to `curl-8.11.1` before matching, then the regex extracts `8.11.1` + ==== semver If `versionFilter.kind` is set to `semver` then we can use `versionFilter.pattern` to specify version pattern as explained link:https://github.com/Masterminds/semver#checking-version-constraints[here]. In the process we also sort. @@ -108,6 +133,10 @@ We can then use `versionFilter.pattern` to specify version pattern as explained If no `versionFilter.pattern` is provided then it fallback to '*' which return the newest version. If a extracted version doesn't respect semantic versioning, then it's not the value is just ignored. +`versionFilter.replaceall` can optionally be used to transform version strings before the regex is applied. +It accepts a `pattern` (regex) and a `replacement` string, similar to a find-and-replace operation. +See the [regex section](#_regexp) for an example. + ===== Example ```