diff --git a/automation/capitanodoc/capitanodoc.ts b/automation/capitanodoc/capitanodoc.ts index acd6d757..e1d9ad5c 100644 --- a/automation/capitanodoc/capitanodoc.ts +++ b/automation/capitanodoc/capitanodoc.ts @@ -58,7 +58,7 @@ const commandHeadings: { [key: string]: string } = { env: 'Environment Variables', envs: 'Environment Variables', help: 'Help and Version', - key: 'SSH Keys', + 'ssh-key': 'SSH Keys', orgs: 'Organizations', os: 'OS', util: 'Utilities', diff --git a/completion/_balena b/completion/_balena index 18907236..e2a2fb3d 100644 --- a/completion/_balena +++ b/completion/_balena @@ -8,7 +8,7 @@ _balena() { local context state line curcontext="$curcontext" # Valid top-level completions - main_commands=( api-key app block build config deploy device devices env envs fleet internal join key leave local login logout logs notes orgs os preload push release scan settings ssh support tag tags tunnel util version whoami ) + main_commands=( api-key app block build config deploy device devices env envs fleet internal join leave local login logout logs notes orgs os preload push release scan settings ssh ssh-key support tag tags tunnel util version whoami ) # Sub-completions api_key_cmds=( generate list revoke ) app_cmds=( create ) @@ -19,10 +19,10 @@ _balena() { env_cmds=( add rename rm ) fleet_cmds=( create list pin purge rename restart rm track-latest ) internal_cmds=( osinit ) - key_cmds=( add list rm ) local_cmds=( configure flash ) os_cmds=( build-config configure download initialize versions ) release_cmds=( finalize invalidate list validate ) + ssh_key_cmds=( add list rm ) tag_cmds=( rm set ) @@ -69,9 +69,6 @@ _balena_sec_cmds() { "internal") _describe -t internal_cmds 'internal_cmd' internal_cmds "$@" && ret=0 ;; - "key") - _describe -t key_cmds 'key_cmd' key_cmds "$@" && ret=0 - ;; "local") _describe -t local_cmds 'local_cmd' local_cmds "$@" && ret=0 ;; @@ -81,6 +78,9 @@ _balena_sec_cmds() { "release") _describe -t release_cmds 'release_cmd' release_cmds "$@" && ret=0 ;; + "ssh-key") + _describe -t ssh_key_cmds 'ssh-key_cmd' ssh_key_cmds "$@" && ret=0 + ;; "tag") _describe -t tag_cmds 'tag_cmd' tag_cmds "$@" && ret=0 ;; diff --git a/completion/balena-completion.bash b/completion/balena-completion.bash index ebdc98b0..106f2b47 100644 --- a/completion/balena-completion.bash +++ b/completion/balena-completion.bash @@ -7,7 +7,7 @@ _balena_complete() local cur prev # Valid top-level completions - main_commands="api-key app block build config deploy device devices env envs fleet internal join key leave local login logout logs notes orgs os preload push release scan settings ssh support tag tags tunnel util version whoami" + main_commands="api-key app block build config deploy device devices env envs fleet internal join leave local login logout logs notes orgs os preload push release scan settings ssh ssh-key support tag tags tunnel util version whoami" # Sub-completions api_key_cmds="generate list revoke" app_cmds="create" @@ -18,10 +18,10 @@ _balena_complete() env_cmds="add rename rm" fleet_cmds="create list pin purge rename restart rm track-latest" internal_cmds="osinit" - key_cmds="add list rm" local_cmds="configure flash" os_cmds="build-config configure download initialize versions" release_cmds="finalize invalidate list validate" + ssh_key_cmds="add list rm" tag_cmds="rm set" @@ -63,9 +63,6 @@ _balena_complete() internal) COMPREPLY=( $(compgen -W "$internal_cmds" -- $cur) ) ;; - key) - COMPREPLY=( $(compgen -W "$key_cmds" -- $cur) ) - ;; local) COMPREPLY=( $(compgen -W "$local_cmds" -- $cur) ) ;; @@ -75,6 +72,9 @@ _balena_complete() release) COMPREPLY=( $(compgen -W "$release_cmds" -- $cur) ) ;; + ssh-key) + COMPREPLY=( $(compgen -W "$ssh_key_cmds" -- $cur) ) + ;; tag) COMPREPLY=( $(compgen -W "$tag_cmds" -- $cur) ) ;; diff --git a/docs/balena-cli.md b/docs/balena-cli.md index 2b2c033b..1072f4fc 100644 --- a/docs/balena-cli.md +++ b/docs/balena-cli.md @@ -294,10 +294,10 @@ are encouraged to regularly update the balena CLI to the latest version. - SSH Keys - - [key add](#key-add) - - [key](#key) - - [key list](#key-list) - - [key rm](#key-rm) + - [ssh-key add](#ssh-key-add) + - [ssh-key](#ssh-key) + - [ssh-key list](#ssh-key-list) + - [ssh-key rm](#ssh-key-rm) - Support @@ -3664,7 +3664,14 @@ Examples: # SSH Keys -## key add +## ssh-key add + +### Aliases + +- `key add` + + +To use one of the aliases, replace `ssh-key add` with the alias. ### Description @@ -3688,10 +3695,10 @@ your balena account. Examples: - $ balena key add Main ~/.ssh/id_rsa.pub - $ cat ~/.ssh/id_rsa.pub | balena key add Main + $ balena ssh-key add Main ~/.ssh/id_rsa.pub + $ cat ~/.ssh/id_rsa.pub | balena ssh-key add Main # Windows 10 (cmd.exe prompt) example - $ balena key add Main %userprofile%.sshid_rsa.pub + $ balena ssh-key add Main %userprofile%.sshid_rsa.pub ### Arguments @@ -3705,7 +3712,14 @@ the path to the public key file ### Options -## key +## ssh-key + +### Aliases + +- `key` + + +To use one of the aliases, replace `ssh-key` with the alias. ### Description @@ -3713,7 +3727,7 @@ Display a single SSH key registered in balenaCloud for the logged in user. Examples: - $ balena key 17 + $ balena ssh-key 17 ### Arguments @@ -3723,14 +3737,15 @@ balenaCloud ID for the SSH key ### Options -## key list +## ssh-key list ### Aliases - `keys` +- `key list` -To use one of the aliases, replace `key list` with the alias. +To use one of the aliases, replace `ssh-key list` with the alias. ### Description @@ -3738,11 +3753,18 @@ List all SSH keys registered in balenaCloud for the logged in user. Examples: - $ balena key list + $ balena ssh-key list ### Options -## key rm +## ssh-key rm + +### Aliases + +- `key rm` + + +To use one of the aliases, replace `ssh-key rm` with the alias. ### Description @@ -3752,8 +3774,8 @@ The --yes option may be used to avoid interactive confirmation. Examples: - $ balena key rm 17 - $ balena key rm 17 --yes + $ balena ssh-key rm 17 + $ balena ssh-key rm 17 --yes ### Arguments diff --git a/src/commands/ssh-key/add.ts b/src/commands/ssh-key/add.ts index 51e075d4..726aab9e 100644 --- a/src/commands/ssh-key/add.ts +++ b/src/commands/ssh-key/add.ts @@ -20,7 +20,9 @@ import { ExpectedError } from '../../errors'; import * as cf from '../../utils/common-flags'; import { getBalenaSdk, stripIndent } from '../../utils/lazy'; -export default class KeyAddCmd extends Command { +export default class SSHKeyAddCmd extends Command { + public static aliases = ['key add']; + public static description = stripIndent` Add an SSH key to balenaCloud. @@ -44,10 +46,10 @@ export default class KeyAddCmd extends Command { `; public static examples = [ - '$ balena key add Main ~/.ssh/id_rsa.pub', - '$ cat ~/.ssh/id_rsa.pub | balena key add Main', + '$ balena ssh-key add Main ~/.ssh/id_rsa.pub', + '$ cat ~/.ssh/id_rsa.pub | balena ssh-key add Main', '# Windows 10 (cmd.exe prompt) example', - '$ balena key add Main %userprofile%.sshid_rsa.pub', + '$ balena ssh-key add Main %userprofile%.sshid_rsa.pub', ]; public static args = { @@ -67,7 +69,7 @@ export default class KeyAddCmd extends Command { public static authenticated = true; public async run() { - const { args: params } = await this.parse(KeyAddCmd); + const { args: params } = await this.parse(SSHKeyAddCmd); let key: string; if (params.path != null) { diff --git a/src/commands/ssh-key/index.ts b/src/commands/ssh-key/index.ts index ebe90ef2..95b128fb 100644 --- a/src/commands/ssh-key/index.ts +++ b/src/commands/ssh-key/index.ts @@ -20,14 +20,16 @@ import * as cf from '../../utils/common-flags'; import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy'; import { parseAsInteger } from '../../utils/validation'; -export default class KeyCmd extends Command { +export default class SSHKeyCmd extends Command { + public static aliases = ['key']; + public static description = stripIndent` Display an SSH key. Display a single SSH key registered in balenaCloud for the logged in user. `; - public static examples = ['$ balena key 17']; + public static examples = ['$ balena ssh-key 17']; public static args = { id: Args.integer({ @@ -44,7 +46,7 @@ export default class KeyCmd extends Command { public static authenticated = true; public async run() { - const { args: params } = await this.parse(KeyCmd); + const { args: params } = await this.parse(SSHKeyCmd); const key = await getBalenaSdk().models.key.get(params.id); diff --git a/src/commands/ssh-key/list.ts b/src/commands/ssh-key/list.ts index baef336a..78ca85ce 100644 --- a/src/commands/ssh-key/list.ts +++ b/src/commands/ssh-key/list.ts @@ -19,15 +19,15 @@ import { Command } from '@oclif/core'; import * as cf from '../../utils/common-flags'; import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy'; -export default class KeyListCmd extends Command { - public static aliases = ['keys']; +export default class SSHKeyListCmd extends Command { + public static aliases = ['keys', 'key list']; public static description = stripIndent` List the SSH keys in balenaCloud. List all SSH keys registered in balenaCloud for the logged in user. `; - public static examples = ['$ balena key list']; + public static examples = ['$ balena ssh-key list']; public static flags = { help: cf.help, @@ -36,7 +36,7 @@ export default class KeyListCmd extends Command { public static authenticated = true; public async run() { - await this.parse(KeyListCmd); + await this.parse(SSHKeyListCmd); const keys = await getBalenaSdk().models.key.getAll(); diff --git a/src/commands/ssh-key/rm.ts b/src/commands/ssh-key/rm.ts index b6f31712..05920e2a 100644 --- a/src/commands/ssh-key/rm.ts +++ b/src/commands/ssh-key/rm.ts @@ -20,7 +20,9 @@ import * as cf from '../../utils/common-flags'; import { getBalenaSdk, stripIndent } from '../../utils/lazy'; import { parseAsInteger } from '../../utils/validation'; -export default class KeyRmCmd extends Command { +export default class SSHKeyRmCmd extends Command { + public static aliases = ['key rm']; + public static description = stripIndent` Remove an SSH key from balenaCloud. @@ -29,7 +31,10 @@ export default class KeyRmCmd extends Command { The --yes option may be used to avoid interactive confirmation. `; - public static examples = ['$ balena key rm 17', '$ balena key rm 17 --yes']; + public static examples = [ + '$ balena ssh-key rm 17', + '$ balena ssh-key rm 17 --yes', + ]; public static args = { id: Args.integer({ @@ -47,7 +52,7 @@ export default class KeyRmCmd extends Command { public static authenticated = true; public async run() { - const { args: params, flags: options } = await this.parse(KeyRmCmd); + const { args: params, flags: options } = await this.parse(SSHKeyRmCmd); const patterns = await import('../../utils/patterns'); diff --git a/tests/commands/help.spec.ts b/tests/commands/help.spec.ts index 4ae5898d..84123167 100644 --- a/tests/commands/help.spec.ts +++ b/tests/commands/help.spec.ts @@ -70,10 +70,10 @@ ADDITIONAL COMMANDS env rename change the value of a config or env var for an app, device or service env rm remove a config or env var from an application, device or service envs list the environment or config variables of an application, device or service - key display an SSH key - key add [path] add an SSH key to balenaCloud - key list list the SSH keys in balenaCloud - key rm remove an SSH key from balenaCloud + ssh-key display an SSH key + ssh-key add [path] add an SSH key to balenaCloud + ssh-key list list the SSH keys in balenaCloud + ssh-key rm remove an SSH key from balenaCloud local configure (Re)configure a balenaOS drive or image local flash flash an image to a drive logout logout from balena diff --git a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt index ac9a59e5..a5a5cf04 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt @@ -172,18 +172,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/join/index.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/add.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/index.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/list.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/leave/index.js @@ -253,6 +241,18 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/ssh/index.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/add.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/index.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/list.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/support/index.js diff --git a/tests/test-data/pkg/expected-warnings-darwin-x64.txt b/tests/test-data/pkg/expected-warnings-darwin-x64.txt index e21bbb34..3dae35d4 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-x64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-x64.txt @@ -172,18 +172,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/join/index.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/add.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/index.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/list.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/leave/index.js @@ -253,6 +241,18 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/ssh/index.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/add.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/index.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/list.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/support/index.js diff --git a/tests/test-data/pkg/expected-warnings-linux-arm64.txt b/tests/test-data/pkg/expected-warnings-linux-arm64.txt index ac9a59e5..a5a5cf04 100644 --- a/tests/test-data/pkg/expected-warnings-linux-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-arm64.txt @@ -172,18 +172,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/join/index.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/add.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/index.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/list.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/leave/index.js @@ -253,6 +241,18 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/ssh/index.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/add.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/index.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/list.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/support/index.js diff --git a/tests/test-data/pkg/expected-warnings-linux-x64.txt b/tests/test-data/pkg/expected-warnings-linux-x64.txt index e21bbb34..3dae35d4 100644 --- a/tests/test-data/pkg/expected-warnings-linux-x64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-x64.txt @@ -172,18 +172,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/join/index.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/add.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/index.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/list.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/leave/index.js @@ -253,6 +241,18 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/ssh/index.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/add.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/index.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/list.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/ssh-key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/support/index.js diff --git a/tests/test-data/pkg/expected-warnings-win32-x64.txt b/tests/test-data/pkg/expected-warnings-win32-x64.txt index b51680c6..1ed9f39f 100644 --- a/tests/test-data/pkg/expected-warnings-win32-x64.txt +++ b/tests/test-data/pkg/expected-warnings-win32-x64.txt @@ -172,18 +172,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\join\index.js -> Warning Entry 'main' not found in %1 - %1: node_modules\@oclif\core\package.json - %2: build\commands\key\add.js -> Warning Entry 'main' not found in %1 - %1: node_modules\@oclif\core\package.json - %2: build\commands\key\index.js -> Warning Entry 'main' not found in %1 - %1: node_modules\@oclif\core\package.json - %2: build\commands\key\list.js -> Warning Entry 'main' not found in %1 - %1: node_modules\@oclif\core\package.json - %2: build\commands\key\rm.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\leave\index.js @@ -253,6 +241,18 @@ > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\ssh\index.js +> Warning Entry 'main' not found in %1 + %1: node_modules\@oclif\core\package.json + %2: build\commands\ssh-key\add.js +> Warning Entry 'main' not found in %1 + %1: node_modules\@oclif\core\package.json + %2: build\commands\ssh-key\index.js +> Warning Entry 'main' not found in %1 + %1: node_modules\@oclif\core\package.json + %2: build\commands\ssh-key\list.js +> Warning Entry 'main' not found in %1 + %1: node_modules\@oclif\core\package.json + %2: build\commands\ssh-key\rm.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\support\index.js