Add provisioning key name option to config generate options

Change-Type: minor
Signed-off-by: Nitish Agarwal 1592163+nitishagar@users.noreply.github.com
This commit is contained in:
Nitish Agarwal 2021-07-20 12:12:15 +05:30
parent 3b885ad906
commit 6ba67eefdb
5 changed files with 47 additions and 2 deletions

View File

@ -999,6 +999,10 @@ Check `balena util available-drives` for available options.
path to the config JSON file, see `balena os build-config`
#### --provisioning-key-name PROVISIONING-KEY-NAME
custom key name assigned to generated provisioning api key
## device local-mode <uuid>
Output current local mode status, or enable/disable local mode
@ -2479,6 +2483,10 @@ balenaOS version, for example "2.32.0" or "2.44.0+rev1"
paths to local files to place into the 'system-connections' directory
#### --provisioning-key-name PROVISIONING-KEY-NAME
custom key name assigned to generated provisioning api key
## os initialize <image>
Initialize an os image for a device with a previously
@ -2606,6 +2614,10 @@ the wifi ssid to use (used only if --network is set to wifi)
the wifi key to use (used only if --network is set to wifi)
#### --provisioning-key-name PROVISIONING-KEY-NAME
custom key name assigned to generated provisioning api key
## config inject <file>
Inject a 'config.json' file to a balenaOS image file or attached SD card or

View File

@ -42,6 +42,7 @@ interface FlagsDef {
wifiSsid?: string;
wifiKey?: string;
appUpdatePollInterval?: string;
'provisioning-key-name'?: string;
help: void;
}
@ -94,7 +95,10 @@ export default class ConfigGenerateCmd extends Command {
}),
}),
fleet: { ...cf.fleet, exclusive: ['application', 'app', 'device'] },
device: { ...cf.device, exclusive: ['application', 'app', 'fleet'] },
device: {
...cf.device,
exclusive: ['application', 'app', 'fleet', 'provisioning-key-name'],
},
deviceApiKey: flags.string({
description:
'custom device key - note that this is only supported on balenaOS 2.0.3+',
@ -128,6 +132,10 @@ export default class ConfigGenerateCmd extends Command {
description:
'supervisor cloud polling interval in minutes (e.g. for variable updates)',
}),
'provisioning-key-name': flags.string({
description: 'custom key name assigned to generated provisioning api key',
exclusive: ['device'],
}),
help: cf.help,
};
@ -202,6 +210,7 @@ export default class ConfigGenerateCmd extends Command {
override: options,
});
answers.version = options.version;
answers.provisioningKeyName = options['provisioning-key-name'];
// Generate config
const { generateDeviceConfig, generateApplicationConfig } = await import(

View File

@ -37,6 +37,7 @@ interface FlagsDef {
drive?: string;
config?: string;
help: void;
'provisioning-key-name'?: string;
}
export default class DeviceInitCmd extends Command {
@ -106,6 +107,9 @@ export default class DeviceInitCmd extends Command {
config: flags.string({
description: 'path to the config JSON file, see `balena os build-config`',
}),
'provisioning-key-name': flags.string({
description: 'custom key name assigned to generated provisioning api key',
}),
help: cf.help,
};
@ -194,6 +198,13 @@ export default class DeviceInitCmd extends Command {
} else if (options.advanced) {
configureCommand.push('--advanced');
}
if (options['provisioning-key-name']) {
configureCommand.push(
'--provisioning-key-name',
options['provisioning-key-name'],
);
}
await runCommand(configureCommand);
}

View File

@ -49,6 +49,7 @@ interface FlagsDef {
version?: string;
'system-connection': string[];
'initial-device-name'?: string;
'provisioning-key-name'?: string;
}
interface ArgsDef {
@ -62,6 +63,7 @@ interface Answers {
version: string; // e.g. "2.32.0+rev1"
wifiSsid?: string;
wifiKey?: string;
provisioningKeyName?: string;
}
const deviceApiKeyDeprecationMsg = stripIndent`
@ -145,6 +147,7 @@ export default class OsConfigureCmd extends Command {
config: flags.string({
description:
'path to a pre-generated config.json file to be injected in the OS image',
exclusive: ['provisioning-key-name'],
}),
'config-app-update-poll-interval': flags.integer({
description:
@ -160,7 +163,10 @@ export default class OsConfigureCmd extends Command {
'config-wifi-ssid': flags.string({
description: 'WiFi SSID (network name) (non-interactive configuration)',
}),
device: { exclusive: ['app', 'application', 'fleet'], ...cf.device },
device: {
exclusive: ['app', 'application', 'fleet', 'provisioning-key-name'],
...cf.device,
},
'device-api-key': flags.string({
char: 'k',
description:
@ -184,6 +190,10 @@ export default class OsConfigureCmd extends Command {
description:
"paths to local files to place into the 'system-connections' directory",
}),
'provisioning-key-name': flags.string({
description: 'custom key name assigned to generated provisioning api key',
exclusive: ['config', 'device'],
}),
help: cf.help,
};
@ -256,6 +266,8 @@ export default class OsConfigureCmd extends Command {
options.version ||
(await getOsVersionFromImage(params.image, deviceTypeManifest, devInit));
answers.provisioningKeyName = options['provisioning-key-name'];
if (_.isEmpty(configJson)) {
if (device) {
configJson = await generateDeviceConfig(

View File

@ -58,6 +58,7 @@ if (process.platform !== 'win32') {
'--config-app-update-poll-interval 10',
'--config-network ethernet',
'--initial-device-name testDeviceName',
'--provisioning-key-name testKey',
];
const { err } = await runCommand(command.join(' '));