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

docs(datasource): Add additional examples for custom datasource #23558

Merged
merged 8 commits into from
Aug 1, 2023
90 changes: 89 additions & 1 deletion lib/modules/datasource/custom/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

## Examples

# K3s
### K3s

You can use this configuration to request the newest version available to [K3s](https://k3s.io/)

Expand All @@ -98,3 +98,91 @@
},
}
```

### Hashicorp

You can use this configuration to request the newest versions of the hashicorp products:
SirUli marked this conversation as resolved.
Show resolved Hide resolved

```json
{
"regexManagers": [
{
"fileMatch": ["\\.yml$"],
"datasourceTemplate": "custom.hashicorp",
"matchStrings": [
"#\\s*renovate:\\s*(datasource=(?<datasource>.*?) )?depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\s*\\w*:\\s*(?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}"
}
],
"customDatasources": {
"hashicorp": {
"defaultRegistryUrlTemplate": "https://api.releases.hashicorp.com/v1/releases/{{packageName}}?license_class=oss",
"transformTemplates": [
"{ \"releases\": $map($, function($v) { { \"version\": $v.version, \"releaseTimestamp\": $v.timestamp_created, \"changelogUrl\": $v.url_changelog, \"sourceUrl\": $v.url_source_repository } }), \"homepage\": $[0].url_project_website, \"sourceUrl\": $[0].url_source_repository }"
]
}
},
}
```

Check failure on line 128 in lib/modules/datasource/custom/readme.md

View workflow job for this annotation

GitHub Actions / lint-docs

Invalid JSON in fenced code block

Unexpected token } in JSON at position 891. Fix this manually by ensuring each block is a valid, complete JSON document.
E.g. to have the latest Nomad version in your ansible variables, use this snippet after adding the above configuration:
SirUli marked this conversation as resolved.
Show resolved Hide resolved

```yaml
# renovate: depName=nomad
nomad_version: 1.6.0
```

### Custom Offline Dependencies
SirUli marked this conversation as resolved.
Show resolved Hide resolved

Sometimes the source of the dependency versions is not available via an API but has to be generated manually. For this purpose, you can manually create dependency "files" (similar to an API) served via http(s) for renovate to access. For example, imagine the following file `versiontracker.json` for the software `something``:
SirUli marked this conversation as resolved.
Show resolved Hide resolved

```json
[
{
"version": "77"
},
{
"version": "76"
},
]
```

Check failure on line 150 in lib/modules/datasource/custom/readme.md

View workflow job for this annotation

GitHub Actions / lint-docs

Invalid JSON in fenced code block

Unexpected token ] in JSON at position 76. Fix this manually by ensuring each block is a valid, complete JSON document.
Which can be ingested by renovate using the following custom datasource (using nexus as a webserver in this case):
SirUli marked this conversation as resolved.
Show resolved Hide resolved

```json
{
"customDatasources": {
"nexus_generic": {
"defaultRegistryUrlTemplate": "https://nexus.example.com/repository/versiontrackers/{{packageName}}/versiontracker.json",
"transformTemplates": [
"{ \"releases\": $map($, function($v) { { \"version\": $v.version, \"sourceUrl\": $v.filelink } }) }"
]
}
},
}
```

Check failure on line 165 in lib/modules/datasource/custom/readme.md

View workflow job for this annotation

GitHub Actions / lint-docs

Invalid JSON in fenced code block

Unexpected token } in JSON at position 337. Fix this manually by ensuring each block is a valid, complete JSON document.
This could be used to update ansible yaml files with the latest version through a regex manager, e.g. with the following ansible content:
SirUli marked this conversation as resolved.
Show resolved Hide resolved

```yaml
# renovate: datasource=custom.nexus_generic depName=something versioning=loose
something_version: "77"
```

And the following regex manager:

```json
{
"regexManagers": [
{
"fileMatch": ["\\.yml$"],
"datasourceTemplate": "custom.nexus_generic",
"matchStrings": [
"#\\s*renovate:\\s*(datasource=(?<datasource>.*?) )?depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\s*\\w*:\\s*\"?(?<currentValue>.+?)\"?\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}"
}
],
}
```
Loading