You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/plugins/_versionFilter.adoc
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,9 @@ If `versionFilter.kind` is set to `regex` then we can use `versionFilter.pattern
57
57
return the newest version returned from a resource matching the regex
58
58
If no versionFilter.pattern is provided then it uses '.*' which return the newest version
59
59
60
+
`versionFilter.replaceall` can optionally be used to transform version strings before the regex is applied.
61
+
It accepts a `pattern` (regex) and a `replacement` string, similar to a find-and-replace operation.
62
+
60
63
```
61
64
sources:
62
65
kubectl:
@@ -74,6 +77,28 @@ sources:
74
77
```
75
78
=> Return the newest kubectl version matching pattern "kubernetes-1.(\\d*).(\\d*)$" and remove "kubernetes-" from it
76
79
80
+
===== Example with replaceall
81
+
82
+
Some projects use version tags that are not directly compatible with the regex pattern. For example, curl uses tags like
83
+
`curl-8_11_1` where underscores separate version components.
84
+
The `replaceall` option can be used to normalize these tags before applying the regex.
85
+
86
+
```yaml
87
+
sources:
88
+
curl:
89
+
kind: githubRelease
90
+
spec:
91
+
owner: "curl"
92
+
repository: "curl"
93
+
versionFilter:
94
+
kind: regex
95
+
regex: 'curl-(\d+\.\d+\.\d+)'
96
+
replaceall:
97
+
pattern: "_"
98
+
replacement: "."
99
+
```
100
+
=> The `replaceall` converts `curl-8_11_1` to `curl-8.11.1` before matching, then the regex extracts `8.11.1`
101
+
77
102
==== semver
78
103
79
104
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
108
133
If no `versionFilter.pattern` is provided then it fallback to '*' which return the newest version.
109
134
If a extracted version doesn't respect semantic versioning, then it's not the value is just ignored.
110
135
136
+
`versionFilter.replaceall` can optionally be used to transform version strings before the regex is applied.
137
+
It accepts a `pattern` (regex) and a `replacement` string, similar to a find-and-replace operation.
0 commit comments