Add ssh-key as aliases for all key commands

Change-type: minor
This commit is contained in:
myarmolinsky 2024-09-25 07:32:08 -04:00
parent 96cf380f66
commit e853b15f12
14 changed files with 137 additions and 106 deletions

View File

@ -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',

View File

@ -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
;;

View File

@ -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) )
;;

View File

@ -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

View File

@ -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) {

View File

@ -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);

View File

@ -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();

View File

@ -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');

View File

@ -70,10 +70,10 @@ ADDITIONAL COMMANDS
env rename <name> <value> change the value of a config or env var for an app, device or service
env rm <id> 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 <id> display an SSH key
key add <name> [path] add an SSH key to balenaCloud
key list list the SSH keys in balenaCloud
key rm <id> remove an SSH key from balenaCloud
ssh-key <id> display an SSH key
ssh-key add <name> [path] add an SSH key to balenaCloud
ssh-key list list the SSH keys in balenaCloud
ssh-key rm <id> remove an SSH key from balenaCloud
local configure <target> (Re)configure a balenaOS drive or image
local flash <image> flash an image to a drive
logout logout from balena

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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