Closed larsl-net closed 2 years ago
Good idea!
Right, I've got this working on the branch linked to this issue. Tested it working with that Authentik URL. Have made it support both RegEx and JSON filtering of the version from that page, so it should support regular pages if they're like Gitea and display the current version. Authentik threw me off for a bit requiring the header to be 'bearer API_KEY' and not just 'API_KEY'. I haven't tested basic_auth, but it looks like a standard feature in the http library, so I've just allowed that as a param and added a req.SetBasicAuth(Username, Password)
.
Authentik:
deployed_version:
url: https://authentik.example.io/api/v3/admin/version/
headers:
- key: Authorization
value: bearer API_KEY
json: version_current
Gitea:
deployed_version:
url: https://gitea.example.io
regex: 'Powered by Gitea Version: ([0-9.]+) '
I'll put together some info for the site and most likely release this on Friday (today).
(I do want to add some kind of indicator to the front-end if the service has a deployed_version
checker as well as WebHook(s) so that they don't get spammed)
Thanks for suggesting this as a feature, I hadn't even thought of it!😄
The current implementation works.
However, I have discovered a point that can lead to problems. With JSON returns it is not possible to use a path for the version.
Example return from Wiki.js:
{"data":{"system":{"info":{"currentVersion":"2.5.278"}}}}
From me originally expected json
specification was data.system.info.currentVersion
which however does not work.
The actual working solution is to use only the last part in this case currentVersion
.
service:
requarks/wiki:
type: github
url: requarks/wiki
url_commands:
- type: regex_submatch
regex: v([0-9.]+)$
regex_version: ^[0-9.]+$
web_url: https://github.com/requarks/wiki/releases/tag/v{{ version }}
icon: https://static.requarks.io/logo/wikijs-butterfly.svg
deployed_version:
url: https://wiki.example.io/graphql?query=%7Bsystem%7Binfo%7BcurrentVersion%7D%7D%7D
headers:
- key: Authorization
value: Bearer <TOKEN>
json: currentVersion
I think it would be good to support specifying a path in case the required key exists multiple times. A theoretical example where the current version might cause problems
{
"Part1": {
"version": "1.0.1"
},
"Part2":{
"version": "3.0.1"
}
}
Yeah, I've got JSON as just doing a RegEx for the value of the key. It doesn't actually read it as JSON. Go doesn't seem to support unmarshaling into any JSON, you have to define the vars and those vars could be anything so I just did it this way. If there is multiple keys with the same name, you'd need to use RegEx instead.
I'll have another look for a way to parse the JSON.
https://www.sohamkamani.com/golang/json/ - this seems to give a solution. You unmsrshal to a map[string]interface{}
. I'll work on support for this now
The current version fits. This should probably be documented so that it is clear for other users Should you get the support for it built in it is probably nicer.
Right I've got it parsing the full JSON, partials no longer work as a result, but I think this is better. So if it's status.version
, you can't just do version
Perfect. I tested it with the Wiki.js API and it works.
Is your feature request related to a problem? Please describe. Updating the current version is difficult in setups with many tools and automatic updating.
Describe the solution you'd like The possibility to update the current version of a software automatically via a kind of web monitor. With the possibility to use Basic Auth or Custom Header.
Example an API call for Authentik on https://authentik.example.com/api/v3/admin/version/ to get the current version