mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-23 23:42:24 +00:00
Warn user that api keys will not be shown again in future
This commit is contained in:
parent
0e5f2fe748
commit
834a2f1e4d
@ -188,7 +188,6 @@ environment variable (in the same standard URL format).
|
|||||||
|
|
||||||
## api-key generate <name>
|
## api-key generate <name>
|
||||||
|
|
||||||
|
|
||||||
This command generates a new API key for the current user, with the given
|
This command generates a new API key for the current user, with the given
|
||||||
name. The key will be logged to the console.
|
name. The key will be logged to the console.
|
||||||
|
|
||||||
@ -197,8 +196,7 @@ or to authenticate requests to the API with an 'Authorization: Bearer <key>' hea
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin api-key generate "Jenkins Key"
|
$ resin api-key generate "Jenkins Key"
|
||||||
|
|
||||||
|
|
||||||
# Application
|
# Application
|
||||||
|
|
||||||
|
@ -1,26 +1,36 @@
|
|||||||
import { CommandDefinition } from 'capitano';
|
import { CommandDefinition } from 'capitano';
|
||||||
|
import { stripIndent } from 'common-tags';
|
||||||
|
|
||||||
export const generate: CommandDefinition<{
|
export const generate: CommandDefinition<{
|
||||||
name: string;
|
name: string;
|
||||||
}> = {
|
}> = {
|
||||||
signature: 'api-key generate <name>',
|
signature: 'api-key generate <name>',
|
||||||
description: 'Generate a new API key with the given name',
|
description: 'Generate a new API key with the given name',
|
||||||
help: `
|
help: stripIndent`
|
||||||
This command generates a new API key for the current user, with the given
|
This command generates a new API key for the current user, with the given
|
||||||
name. The key will be logged to the console.
|
name. The key will be logged to the console.
|
||||||
|
|
||||||
This key can be used to log into the CLI using 'resin login --token <key>',
|
This key can be used to log into the CLI using 'resin login --token <key>',
|
||||||
or to authenticate requests to the API with an 'Authorization: Bearer <key>' header.
|
or to authenticate requests to the API with an 'Authorization: Bearer <key>' header.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin api-key generate "Jenkins Key"
|
$ resin api-key generate "Jenkins Key"
|
||||||
`,
|
`,
|
||||||
async action(params, _options, done) {
|
async action(params, _options, done) {
|
||||||
const resin = (await import('resin-sdk')).fromSharedOptions();
|
const resin = (await import('resin-sdk')).fromSharedOptions();
|
||||||
|
|
||||||
resin.models.apiKey.create(params.name).then(key => {
|
resin.models.apiKey
|
||||||
console.log(`Registered api key '${params.name}':\n${key}`);
|
.create(params.name)
|
||||||
}).finally(done);
|
.then(key => {
|
||||||
|
console.log(stripIndent`
|
||||||
|
Registered api key '${params.name}':
|
||||||
|
|
||||||
|
${key}
|
||||||
|
|
||||||
|
This key will not be shown again, so please save it now.
|
||||||
|
`);
|
||||||
|
})
|
||||||
|
.finally(done);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/archiver": "^2.0.1",
|
"@types/archiver": "^2.0.1",
|
||||||
"@types/bluebird": "^3.5.19",
|
"@types/bluebird": "^3.5.19",
|
||||||
|
"@types/common-tags": "^1.4.0",
|
||||||
"@types/es6-promise": "0.0.32",
|
"@types/es6-promise": "0.0.32",
|
||||||
"@types/fs-extra": "^5.0.0",
|
"@types/fs-extra": "^5.0.0",
|
||||||
"@types/is-root": "^1.0.0",
|
"@types/is-root": "^1.0.0",
|
||||||
@ -96,6 +97,7 @@
|
|||||||
"cli-truncate": "^1.1.0",
|
"cli-truncate": "^1.1.0",
|
||||||
"coffeescript": "^1.12.6",
|
"coffeescript": "^1.12.6",
|
||||||
"columnify": "^1.5.2",
|
"columnify": "^1.5.2",
|
||||||
|
"common-tags": "^1.7.2",
|
||||||
"denymount": "^2.2.0",
|
"denymount": "^2.2.0",
|
||||||
"docker-progress": "^3.0.1",
|
"docker-progress": "^3.0.1",
|
||||||
"docker-qemu-transpose": "^0.5.1",
|
"docker-qemu-transpose": "^0.5.1",
|
||||||
|
Loading…
Reference in New Issue
Block a user