From 8f369bd17ef80a9c21d375850ab3f94c0b0e5173 Mon Sep 17 00:00:00 2001 From: Jaroslav Henner <1187265+jarovo@users.noreply.github.com> Date: Wed, 31 Dec 2025 11:30:23 +0100 Subject: [PATCH] Add option to read API key from file --- README.md | 1 + cli/linux/runner.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 75c8d56c..842333ca 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ You can pass in options to the CLI. Here are the key ones: * `--disable-microphone` - disable the microphone. * `--clean` - clear credentials, and re-authenticate. Use this to switch projects or devices. * `--api-key ` - set an API key, useful for automatic authentication with a new project. +* `--api-key-file ` - set an API key to a value read from file. This is useful for automatic authentication with a new project in environments where secrets are managed via files (e.g., Docker compose, Docker Swarm, Kubernetes). * `--greengrass` - utilize the AWS IoT Greengrass authentication context and AWS Secrets Manager to authenticate with a new project. See additional Greegrass notes below. * `--help` - see all options. diff --git a/cli/linux/runner.ts b/cli/linux/runner.ts index 3ef57154..f3744b66 100644 --- a/cli/linux/runner.ts +++ b/cli/linux/runner.ts @@ -56,6 +56,7 @@ program .option('--model-file ', 'Specify model file (either path to .eim, or the socket on which the model is running), ' + 'if not provided the model will be fetched from Edge Impulse') .option('--api-key ', 'API key to authenticate with Edge Impulse (overrides current credentials)') + .option('--api-key-file ', 'File to read the API key from -- to authenticate with Edge Impulse (overrides current credentials)') .option('--download ', 'Just download the model and store it on the file system') .option('--list-targets', 'List all supported targets and inference engines') .option('--force-target ', 'Do not autodetect the target system, but set it by hand (e.g. "runner-linux-aarch64")') @@ -107,7 +108,7 @@ const silentArgv: boolean = !!program.silent; const quantizedArgv: boolean = !!program.quantized; const enableCameraArgv: boolean = !!program.enableCamera; const verboseArgv: boolean = !!program.verbose; -const apiKeyArgv = program.apiKey; +const apiKeyArgv = program.apiKey ?? fs.readFileSync(program.apiKeyFile, 'utf-8').trim() ?? undefined; const greengrassArgv: boolean = !!program.greengrass; const modelFileArgv = program.modelFile; const downloadArgv = program.download;