feat(app/metrics): check token format [skip ci]

This commit is contained in:
lowlighter
2022-01-25 22:05:06 -05:00
parent 80dd8eee30
commit 3c347d4b45
2 changed files with 3 additions and 2 deletions

View File

@@ -145,6 +145,9 @@ async function retry(func, {retries = 1, delay = 0} = {}) {
//Token for data gathering
info("GitHub token", token, {token:true})
//A GitHub token should start with "gh" along an additional letter for type
//See https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats
info("GitHub token format", /^gh[pousr]_/.test(token) ? "correct" : "(old or invalid)")
if (!token)
throw new Error("You must provide a valid GitHub personal token to gather your metrics (see https://github.com/lowlighter/metrics/blob/master/.github/readme/partials/setup/action/setup.md for more informations)")
conf.settings.token = token

View File

@@ -253,13 +253,11 @@ metadata.plugin = async function({__plugins, __templates, name, logger}) {
if ((key in preset)&&(unspecified)) {
console.debug(`metrics/inputs > ${key} has been set by preset value`)
q[key] = preset[key]
continue
}
//From defaults
else if (unspecified) {
console.debug(`metrics/inputs > ${key} has been set by default value`)
q[key] = metadata.inputs[key]?.default
continue
}
//From user
else {