mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-24 07:46:39 +00:00
Add --generate-device-api-key parameter to config generate
Change-Type: minor
This commit is contained in:
parent
af9e1a122d
commit
52f93f8f12
@ -1136,6 +1136,7 @@ that will be asked for the relevant device type.
|
||||
Examples:
|
||||
|
||||
$ resin config generate --device 7cf02a6
|
||||
$ resin config generate --device 7cf02a6 --generate-device-api-key
|
||||
$ resin config generate --device 7cf02a6 --device-api-key <existingDeviceKey>
|
||||
$ resin config generate --device 7cf02a6 --output config.json
|
||||
$ resin config generate --app MyApp
|
||||
@ -1156,6 +1157,10 @@ device uuid
|
||||
|
||||
custom device key - note that this is only supported on ResinOS 2.0.3+
|
||||
|
||||
#### --generate-device-api-key
|
||||
|
||||
generate a fresh device key for the device
|
||||
|
||||
#### --output, -o <output>
|
||||
|
||||
output
|
||||
|
@ -230,6 +230,7 @@ exports.generate =
|
||||
Examples:
|
||||
|
||||
$ resin config generate --device 7cf02a6
|
||||
$ resin config generate --device 7cf02a6 --generate-device-api-key
|
||||
$ resin config generate --device 7cf02a6 --device-api-key <existingDeviceKey>
|
||||
$ resin config generate --device 7cf02a6 --output config.json
|
||||
$ resin config generate --app MyApp
|
||||
@ -240,6 +241,11 @@ exports.generate =
|
||||
commandOptions.optionalApplication
|
||||
commandOptions.optionalDevice
|
||||
commandOptions.optionalDeviceApiKey
|
||||
{
|
||||
signature: 'generate-device-api-key'
|
||||
description: 'generate a fresh device key for the device'
|
||||
boolean: true
|
||||
}
|
||||
{
|
||||
signature: 'output'
|
||||
description: 'output'
|
||||
@ -303,7 +309,7 @@ exports.generate =
|
||||
form.run(formOptions, override: options)
|
||||
.then (answers) ->
|
||||
if resource.uuid?
|
||||
generateDeviceConfig(resource, options.deviceApiKey, answers)
|
||||
generateDeviceConfig(resource, options.deviceApiKey || options['generate-device-api-key'], answers)
|
||||
else
|
||||
generateApplicationConfig(resource, answers)
|
||||
.then (config) ->
|
||||
|
@ -75,7 +75,7 @@ export function generateApplicationConfig(
|
||||
|
||||
export function generateDeviceConfig(
|
||||
device: ResinSdk.Device & { application_name: string },
|
||||
deviceApiKey: string | null,
|
||||
deviceApiKey: string | true | null,
|
||||
options: {},
|
||||
) {
|
||||
return resin.models.application
|
||||
@ -111,9 +111,17 @@ function addApplicationKey(config: any, applicationNameOrId: string | number) {
|
||||
});
|
||||
}
|
||||
|
||||
function addDeviceKey(config: any, uuid: string, customDeviceApiKey: string) {
|
||||
function addDeviceKey(
|
||||
config: any,
|
||||
uuid: string,
|
||||
customDeviceApiKey: string | true,
|
||||
) {
|
||||
return Promise.try(() => {
|
||||
return customDeviceApiKey || resin.models.device.generateDeviceKey(uuid);
|
||||
if (customDeviceApiKey === true) {
|
||||
return resin.models.device.generateDeviceKey(uuid);
|
||||
} else {
|
||||
return customDeviceApiKey;
|
||||
}
|
||||
}).tap(deviceApiKey => {
|
||||
config.deviceApiKey = deviceApiKey;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user