Skip to content

Commit

Permalink
docs: add regex/semver to versionFilter (#2006)
Browse files Browse the repository at this point in the history
* docs: add regex/semver to versionFitler

* fix: skip any empty title
  • Loading branch information
mcwarman authored Dec 24, 2024
1 parent aa1a498 commit e87dd86
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 7 deletions.
2 changes: 2 additions & 0 deletions assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Source:
{{ $len := (len $list) -}}

{{ range $index, $element := $list -}}
{{ if not (eq .Title "") -}}
index.add(
{
id: {{ $index }},
Expand All @@ -124,6 +125,7 @@ Source:
content: {{ .Plain | jsonify }}
}
);
{{ end -}}
{{ end -}}

search.addEventListener('input', show_results, true);
Expand Down
11 changes: 11 additions & 0 deletions content/en/docs/core/versionFilter.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "Version Filter"
description: "Allows to specify the kind of version retrieved from a resource and its version pattern"
menu:
docs:
parent: "core"
weight: 130
toc: true
---

include::content/en/docs/plugins/_versionFilter.adoc[]
33 changes: 29 additions & 4 deletions content/en/docs/plugins/_versionFilter.adoc
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
=== VersionFilter

`versionFilter` allows to specify the kind of version retrieved from a resource and its version pattern.
Default value is "latest" as we want to retrieve the newest version from a resource.

==== latest

If kind is set to `latest` then no need to specify the patter as we gonna retrieve the newest version from the resource.

.Example
===== Example

```
sources:
kubectl:
Expand Down Expand Up @@ -57,7 +56,8 @@ If a version doesn't respect semantic versioning, then it's not the value is jus

In the process we drop any characters not respecting semantic version like in this version "v1.0.0", we drop the "v" but we can added it back using `transformers`.

.example
===== Example

```
jenkins-wiki-exporter:
kind: githubRelease
Expand All @@ -71,3 +71,28 @@ In the process we drop any characters not respecting semantic version like in th
pattern: "~1.10"
```
=> Return the version "v1.10.3"

==== regex/semver

If `versionFilter.kind` is set to `regex/semver` then we can use `versionFilter.regex` to specify a regular expression to extract version numbers.
The regular expression should return the semantic version in the first capturing group.
We can then 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.
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.

===== Example

```
sources:
default:
name: Get latest version
kind: githubrelease
spec:
owner: yarnpkg
repository: berry
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
versionfilter:
kind: regex/semver
regex: "@yarnpkg/cli/(\\d*\\.\\d*\\.\\d*)"
```
=> Return the version "4.5.3"
6 changes: 4 additions & 2 deletions content/en/docs/plugins/resource/gitBranch.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ The git branch resource is a resource designed to be used with the scmID

{{< resourceparameters "sources" "gitbranch" >}}

=== Version Filter

include::content/en/docs/plugins/_versionFilter.adoc[]

== Example

[source,yaml]
----
# updatecli.yaml
{{<include "assets/code_example/docs/plugins/resources/gitbranch/updatecli.yaml">}}
----

include::content/en/docs/plugins/_versionFilter.adoc[]
6 changes: 5 additions & 1 deletion content/en/docs/plugins/resource/gitTag.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ The gittag resource is a resource designed to be used with the scmID

{{< resourceparameters "sources" "gittag" >}}


=== Version Filter

include::content/en/docs/plugins/_versionFilter.adoc[]

== Example

[source,yaml]
Expand All @@ -52,4 +57,3 @@ The gittag resource is a resource designed to be used with the scmID
{{<include "assets/code_example/docs/plugins/resources/gittag/updatecli.yaml">}}
----

include::content/en/docs/plugins/_versionFilter.adoc[]
2 changes: 2 additions & 0 deletions content/en/docs/plugins/resource/github_release.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ It's important to notice that both information are mutually exclusive.

{{< resourceparameters "sources" "githubrelease" >}}

=== Version Filter

include::content/en/docs/plugins/_versionFilter.adoc[]

**Remark**:
Expand Down

0 comments on commit e87dd86

Please sign in to comment.