Add support for token "NOT_NEEDED" for standalone plugins (#83)

This commit is contained in:
Simon Lecoq
2021-01-30 13:51:54 +01:00
committed by GitHub
parent 682e43e10b
commit b74f88a0ee
11 changed files with 42 additions and 11 deletions

View File

@@ -14,7 +14,7 @@
const info = (left, right, {token = false} = {}) => console.log(`${`${left}`.padEnd(56 + 9*(/0m$/.test(left)))}${
Array.isArray(right) ? right.join(", ") || "(none)" :
right === undefined ? "(default)" :
token ? /^MOCKED/.test(right) ? "(MOCKED TOKEN)" : (right ? "(provided)" : "(missing)") :
token ? /^MOCKED/.test(right) ? "(MOCKED TOKEN)" : /^NOT_NEEDED$/.test(right) ? "(NOT NEEDED)" : (right ? "(provided)" : "(missing)") :
typeof right === "object" ? JSON.stringify(right) :
right
}`)
@@ -62,7 +62,7 @@
//Docker image
if (_image)
info("Using prebuilt image", image)
info("Using prebuilt image", _image)
//Debug mode and flags
info("Debug mode", debug)
@@ -76,6 +76,7 @@
info("GitHub token", token, {token:true})
if (!token)
throw new Error("You must provide a valid GitHub token to gather your metrics")
conf.settings.token = token
const api = {}
api.graphql = octokit.graphql.defaults({headers:{authorization: `token ${token}`}})
info("Github GraphQL API", "ok")
@@ -179,7 +180,7 @@
//Register user inputs
if (enabled) {
info.break()
info.group({metadata, name, inputs:enabled ? inputs : {}})
info.group({metadata, name, inputs})
q[name] = true
for (const [key, value] of Object.entries(inputs)) {
//Store token in plugin configuration