voltagegpu-cli 2.0.2__py3-none-any.whl → 2.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- volt/__init__.py +1 -1
- volt/__main__.py +5 -5
- volt/cli/__init__.py +5 -5
- volt/cli/cmd_account.py +179 -179
- volt/cli/cmd_deploy.py +218 -218
- volt/cli/cmd_machines.py +103 -103
- volt/cli/cmd_misc.py +105 -102
- volt/cli/cmd_pods.py +188 -188
- volt/cli/main.py +132 -132
- volt/cli/output.py +98 -98
- volt/cli/state.py +35 -35
- volt/cli/vgpu.py +500 -485
- volt/mcp/__init__.py +1 -1
- volt/mcp/server.py +351 -344
- volt/sdk/__init__.py +36 -36
- volt/sdk/attest.py +317 -296
- volt/sdk/catalog.py +163 -163
- volt/sdk/client.py +240 -240
- volt/sdk/config.py +202 -202
- volt/sdk/errors.py +82 -82
- volt/sdk/fleet.py +220 -220
- volt/sdk/models.py +336 -336
- volt/sdk/remote.py +140 -140
- volt/sdk/ssh.py +157 -157
- volt/sdk/ttl.py +104 -104
- {voltagegpu_cli-2.0.2.dist-info → voltagegpu_cli-2.0.4.dist-info}/METADATA +20 -6
- voltagegpu_cli-2.0.4.dist-info/RECORD +32 -0
- {voltagegpu_cli-2.0.2.dist-info → voltagegpu_cli-2.0.4.dist-info}/entry_points.txt +1 -0
- {voltagegpu_cli-2.0.2.dist-info → voltagegpu_cli-2.0.4.dist-info}/licenses/LICENSE +21 -21
- voltagegpu_cli-2.0.2.dist-info/RECORD +0 -32
- {voltagegpu_cli-2.0.2.dist-info → voltagegpu_cli-2.0.4.dist-info}/WHEEL +0 -0
volt/__init__.py
CHANGED
volt/__main__.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"""`python -m volt` runs the CLI."""
|
|
2
|
-
|
|
3
|
-
from .cli.main import main
|
|
4
|
-
|
|
5
|
-
main()
|
|
1
|
+
"""`python -m volt` runs the CLI."""
|
|
2
|
+
|
|
3
|
+
from .cli.main import main
|
|
4
|
+
|
|
5
|
+
main()
|
volt/cli/__init__.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"""The `voltagegpu` command line."""
|
|
2
|
-
|
|
3
|
-
from .main import cli, main
|
|
4
|
-
|
|
5
|
-
__all__ = ["cli", "main"]
|
|
1
|
+
"""The `voltagegpu` command line."""
|
|
2
|
+
|
|
3
|
+
from .main import cli, main
|
|
4
|
+
|
|
5
|
+
__all__ = ["cli", "main"]
|
volt/cli/cmd_account.py
CHANGED
|
@@ -1,179 +1,179 @@
|
|
|
1
|
-
"""`login`, `logout`, `config`, `balance` and `ssh-keys`."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from typing import Optional
|
|
7
|
-
|
|
8
|
-
import click
|
|
9
|
-
|
|
10
|
-
from ..sdk.config import (
|
|
11
|
-
API_KEYS_PAGE,
|
|
12
|
-
Config,
|
|
13
|
-
default_config_path,
|
|
14
|
-
is_valid_api_key,
|
|
15
|
-
permissions_warning,
|
|
16
|
-
remove_api_key,
|
|
17
|
-
save_api_key,
|
|
18
|
-
)
|
|
19
|
-
from ..sdk.errors import ApiError, ConfigError
|
|
20
|
-
from .output import console, echo_json, esc, fail, hint, info, is_interactive, money, table, warn
|
|
21
|
-
from .state import AppState, pass_state
|
|
22
|
-
|
|
23
|
-
_PUBLIC_KEY_PREFIXES = ("ssh-ed25519 ", "ssh-rsa ", "ecdsa-sha2-", "sk-ssh-ed25519@openssh.com ", "sk-ecdsa-sha2-")
|
|
24
|
-
_DEFAULT_PUBLIC_KEYS = ("id_ed25519.pub", "id_ecdsa.pub", "id_rsa.pub")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def read_public_key(text: str) -> str:
|
|
28
|
-
"""Validate an OpenSSH public key; refuse private keys loudly."""
|
|
29
|
-
key = (text or "").strip()
|
|
30
|
-
if "PRIVATE KEY" in key:
|
|
31
|
-
raise click.BadParameter("this is a PRIVATE key. Never upload it: pass the matching .pub file instead.")
|
|
32
|
-
lines = [line for line in key.splitlines() if line.strip()]
|
|
33
|
-
if len(lines) != 1 or not lines[0].startswith(_PUBLIC_KEY_PREFIXES) or len(lines[0]) > 16384:
|
|
34
|
-
raise click.BadParameter("expected one OpenSSH public key line, e.g. 'ssh-ed25519 AAAA... you@laptop'.")
|
|
35
|
-
return lines[0].strip()
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def default_public_key_file() -> Optional[Path]:
|
|
39
|
-
ssh_dir = Path.home() / ".ssh"
|
|
40
|
-
for name in _DEFAULT_PUBLIC_KEYS:
|
|
41
|
-
candidate = ssh_dir / name
|
|
42
|
-
if candidate.is_file():
|
|
43
|
-
return candidate
|
|
44
|
-
return None
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
@click.command("login")
|
|
48
|
-
@click.option("--api-key", envvar=None, help="Key to store (prompted, hidden, if omitted). Prefer the prompt: "
|
|
49
|
-
"a key on the command line lands in your shell history.")
|
|
50
|
-
@pass_state
|
|
51
|
-
def login_cmd(state: AppState, api_key: Optional[str]) -> None:
|
|
52
|
-
"""Store your API key in ~/.volt/config.ini (readable by you only)."""
|
|
53
|
-
if not api_key:
|
|
54
|
-
if not is_interactive():
|
|
55
|
-
fail("No terminal to prompt on. Export VOLT_API_KEY instead, or pass --api-key.", code=2)
|
|
56
|
-
info(f"Create a key at {API_KEYS_PAGE} (it is shown once).")
|
|
57
|
-
api_key = click.prompt("API key", hide_input=True).strip()
|
|
58
|
-
if not is_valid_api_key(api_key):
|
|
59
|
-
fail(f"That does not look like a VoltageGPU API key (volt_...). Create one at {API_KEYS_PAGE}.")
|
|
60
|
-
try:
|
|
61
|
-
with state.client_with_key(api_key) as client:
|
|
62
|
-
client.list_ssh_keys() # cheapest authenticated call: proves the key works
|
|
63
|
-
except ApiError as exc:
|
|
64
|
-
if exc.is_auth_error:
|
|
65
|
-
fail("The API refused this key. Check it on " + API_KEYS_PAGE)
|
|
66
|
-
raise
|
|
67
|
-
path = save_api_key(api_key)
|
|
68
|
-
console.print(f"[green]Logged in.[/green] Key saved to {esc(path)}")
|
|
69
|
-
hint("Environment variables (VOLT_API_KEY) take precedence over this file.")
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
@click.command("logout")
|
|
73
|
-
def logout_cmd() -> None:
|
|
74
|
-
"""Remove the stored API key from ~/.volt/config.ini."""
|
|
75
|
-
if remove_api_key():
|
|
76
|
-
info(f"Removed the key from {esc(default_config_path())}. Revoke it too on {API_KEYS_PAGE} if it may have leaked.")
|
|
77
|
-
else:
|
|
78
|
-
info("No stored key.")
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
@click.command("config")
|
|
82
|
-
@pass_state
|
|
83
|
-
def config_cmd(state: AppState) -> None:
|
|
84
|
-
"""Show where the API key comes from (masked) and the API base URL."""
|
|
85
|
-
try:
|
|
86
|
-
cfg = Config.load(base_url=state.base_url)
|
|
87
|
-
except ConfigError as exc:
|
|
88
|
-
fail(str(exc))
|
|
89
|
-
info(f"API base URL {esc(cfg.base_url)}")
|
|
90
|
-
info(f"API key {esc(cfg.masked_key)} from {esc(cfg.source)}")
|
|
91
|
-
warning = permissions_warning(default_config_path())
|
|
92
|
-
if warning:
|
|
93
|
-
warn(warning)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
@click.command("balance")
|
|
97
|
-
@click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
|
|
98
|
-
@pass_state
|
|
99
|
-
def balance_cmd(state: AppState, as_json: bool) -> None:
|
|
100
|
-
"""Your balance and number of running pods."""
|
|
101
|
-
try:
|
|
102
|
-
bal = state.client().get_balance()
|
|
103
|
-
except ApiError as exc:
|
|
104
|
-
if exc.is_not_found:
|
|
105
|
-
fail("This API server does not expose the balance yet. See it on https://voltagegpu.com/billing")
|
|
106
|
-
raise
|
|
107
|
-
if as_json:
|
|
108
|
-
echo_json(bal.to_dict())
|
|
109
|
-
return
|
|
110
|
-
if bal.balance is None:
|
|
111
|
-
info(f"Balance hidden: {esc(bal.balance_hidden or 'this key cannot read the account balance')}")
|
|
112
|
-
else:
|
|
113
|
-
console.print(f"Balance [bold green]{money(bal.balance)}[/bold green] {esc(bal.currency)}")
|
|
114
|
-
if bal.active_pods is not None:
|
|
115
|
-
info(f"Running {bal.active_pods} pod{'s' if bal.active_pods != 1 else ''}")
|
|
116
|
-
hint(f"Top up: {esc(bal.top_up_url)}")
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
@click.group("ssh-keys")
|
|
120
|
-
def ssh_keys_group() -> None:
|
|
121
|
-
"""Manage the SSH public keys injected into your pods."""
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
@ssh_keys_group.command("list")
|
|
125
|
-
@click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
|
|
126
|
-
@pass_state
|
|
127
|
-
def ssh_keys_list(state: AppState, as_json: bool) -> None:
|
|
128
|
-
"""List your SSH keys."""
|
|
129
|
-
keys = state.client().list_ssh_keys()
|
|
130
|
-
if as_json:
|
|
131
|
-
echo_json([k.to_dict() for k in keys])
|
|
132
|
-
return
|
|
133
|
-
if not keys:
|
|
134
|
-
info("No SSH key yet. Add one: voltagegpu ssh-keys add")
|
|
135
|
-
return
|
|
136
|
-
table("SSH keys", [("KEY ID", {"style": "cyan", "no_wrap": True}), ("NAME",), ("KEY",), ("ADDED",)],
|
|
137
|
-
[(k.id, k.name, k.summary, (k.created_at or "")[:10]) for k in keys])
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
@ssh_keys_group.command("add")
|
|
141
|
-
@click.option("--name", help="Label for the key (default: the file name).")
|
|
142
|
-
@click.option("--file", "key_file", type=click.Path(exists=True, dir_okay=False, path_type=Path),
|
|
143
|
-
help="Public key file (default: ~/.ssh/id_ed25519.pub, id_ecdsa.pub or id_rsa.pub).")
|
|
144
|
-
@click.option("--key", "key_text", help="Public key string instead of a file.")
|
|
145
|
-
@click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
|
|
146
|
-
@pass_state
|
|
147
|
-
def ssh_keys_add(state: AppState, name: Optional[str], key_file: Optional[Path], key_text: Optional[str], as_json: bool) -> None:
|
|
148
|
-
"""Register an SSH public key."""
|
|
149
|
-
if key_file and key_text:
|
|
150
|
-
fail("Give --file or --key, not both.", code=2)
|
|
151
|
-
if not key_text:
|
|
152
|
-
path = key_file or default_public_key_file()
|
|
153
|
-
if path is None:
|
|
154
|
-
fail("No public key found in ~/.ssh. Create one with: ssh-keygen -t ed25519", code=2)
|
|
155
|
-
if path.suffix != ".pub" and path.with_suffix(path.suffix + ".pub").exists():
|
|
156
|
-
fail(f"{path} looks like a private key. Use {path}.pub", code=2)
|
|
157
|
-
key_text = path.read_text(encoding="utf-8", errors="replace")
|
|
158
|
-
name = name or path.name
|
|
159
|
-
public_key = read_public_key(key_text)
|
|
160
|
-
key = state.client().add_ssh_key(name or "cli-key", public_key)
|
|
161
|
-
if as_json:
|
|
162
|
-
echo_json(key.to_dict())
|
|
163
|
-
else:
|
|
164
|
-
console.print(f"[green]Added.[/green] {esc(key.name)} ({esc(key.id)})")
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
@ssh_keys_group.command("delete")
|
|
168
|
-
@click.argument("key_id")
|
|
169
|
-
@click.option("-y", "--yes", is_flag=True, help="Do not ask for confirmation.")
|
|
170
|
-
@pass_state
|
|
171
|
-
def ssh_keys_delete(state: AppState, key_id: str, yes: bool) -> None:
|
|
172
|
-
"""Delete an SSH key (running pods keep the keys they were created with)."""
|
|
173
|
-
if not yes:
|
|
174
|
-
if not is_interactive():
|
|
175
|
-
fail("Re-run with --yes to confirm in a script.", code=2)
|
|
176
|
-
if not click.confirm(f"Delete SSH key {key_id}?", default=False):
|
|
177
|
-
raise click.exceptions.Exit(1)
|
|
178
|
-
state.client().delete_ssh_key(key_id)
|
|
179
|
-
console.print(f"[green]Deleted.[/green] {esc(key_id)}")
|
|
1
|
+
"""`login`, `logout`, `config`, `balance` and `ssh-keys`."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
import click
|
|
9
|
+
|
|
10
|
+
from ..sdk.config import (
|
|
11
|
+
API_KEYS_PAGE,
|
|
12
|
+
Config,
|
|
13
|
+
default_config_path,
|
|
14
|
+
is_valid_api_key,
|
|
15
|
+
permissions_warning,
|
|
16
|
+
remove_api_key,
|
|
17
|
+
save_api_key,
|
|
18
|
+
)
|
|
19
|
+
from ..sdk.errors import ApiError, ConfigError
|
|
20
|
+
from .output import console, echo_json, esc, fail, hint, info, is_interactive, money, table, warn
|
|
21
|
+
from .state import AppState, pass_state
|
|
22
|
+
|
|
23
|
+
_PUBLIC_KEY_PREFIXES = ("ssh-ed25519 ", "ssh-rsa ", "ecdsa-sha2-", "sk-ssh-ed25519@openssh.com ", "sk-ecdsa-sha2-")
|
|
24
|
+
_DEFAULT_PUBLIC_KEYS = ("id_ed25519.pub", "id_ecdsa.pub", "id_rsa.pub")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def read_public_key(text: str) -> str:
|
|
28
|
+
"""Validate an OpenSSH public key; refuse private keys loudly."""
|
|
29
|
+
key = (text or "").strip()
|
|
30
|
+
if "PRIVATE KEY" in key:
|
|
31
|
+
raise click.BadParameter("this is a PRIVATE key. Never upload it: pass the matching .pub file instead.")
|
|
32
|
+
lines = [line for line in key.splitlines() if line.strip()]
|
|
33
|
+
if len(lines) != 1 or not lines[0].startswith(_PUBLIC_KEY_PREFIXES) or len(lines[0]) > 16384:
|
|
34
|
+
raise click.BadParameter("expected one OpenSSH public key line, e.g. 'ssh-ed25519 AAAA... you@laptop'.")
|
|
35
|
+
return lines[0].strip()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def default_public_key_file() -> Optional[Path]:
|
|
39
|
+
ssh_dir = Path.home() / ".ssh"
|
|
40
|
+
for name in _DEFAULT_PUBLIC_KEYS:
|
|
41
|
+
candidate = ssh_dir / name
|
|
42
|
+
if candidate.is_file():
|
|
43
|
+
return candidate
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@click.command("login")
|
|
48
|
+
@click.option("--api-key", envvar=None, help="Key to store (prompted, hidden, if omitted). Prefer the prompt: "
|
|
49
|
+
"a key on the command line lands in your shell history.")
|
|
50
|
+
@pass_state
|
|
51
|
+
def login_cmd(state: AppState, api_key: Optional[str]) -> None:
|
|
52
|
+
"""Store your API key in ~/.volt/config.ini (readable by you only)."""
|
|
53
|
+
if not api_key:
|
|
54
|
+
if not is_interactive():
|
|
55
|
+
fail("No terminal to prompt on. Export VOLT_API_KEY instead, or pass --api-key.", code=2)
|
|
56
|
+
info(f"Create a key at {API_KEYS_PAGE} (it is shown once).")
|
|
57
|
+
api_key = click.prompt("API key", hide_input=True).strip()
|
|
58
|
+
if not is_valid_api_key(api_key):
|
|
59
|
+
fail(f"That does not look like a VoltageGPU API key (volt_...). Create one at {API_KEYS_PAGE}.")
|
|
60
|
+
try:
|
|
61
|
+
with state.client_with_key(api_key) as client:
|
|
62
|
+
client.list_ssh_keys() # cheapest authenticated call: proves the key works
|
|
63
|
+
except ApiError as exc:
|
|
64
|
+
if exc.is_auth_error:
|
|
65
|
+
fail("The API refused this key. Check it on " + API_KEYS_PAGE)
|
|
66
|
+
raise
|
|
67
|
+
path = save_api_key(api_key)
|
|
68
|
+
console.print(f"[green]Logged in.[/green] Key saved to {esc(path)}")
|
|
69
|
+
hint("Environment variables (VOLT_API_KEY) take precedence over this file.")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@click.command("logout")
|
|
73
|
+
def logout_cmd() -> None:
|
|
74
|
+
"""Remove the stored API key from ~/.volt/config.ini."""
|
|
75
|
+
if remove_api_key():
|
|
76
|
+
info(f"Removed the key from {esc(default_config_path())}. Revoke it too on {API_KEYS_PAGE} if it may have leaked.")
|
|
77
|
+
else:
|
|
78
|
+
info("No stored key.")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@click.command("config")
|
|
82
|
+
@pass_state
|
|
83
|
+
def config_cmd(state: AppState) -> None:
|
|
84
|
+
"""Show where the API key comes from (masked) and the API base URL."""
|
|
85
|
+
try:
|
|
86
|
+
cfg = Config.load(base_url=state.base_url)
|
|
87
|
+
except ConfigError as exc:
|
|
88
|
+
fail(str(exc))
|
|
89
|
+
info(f"API base URL {esc(cfg.base_url)}")
|
|
90
|
+
info(f"API key {esc(cfg.masked_key)} from {esc(cfg.source)}")
|
|
91
|
+
warning = permissions_warning(default_config_path())
|
|
92
|
+
if warning:
|
|
93
|
+
warn(warning)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@click.command("balance")
|
|
97
|
+
@click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
|
|
98
|
+
@pass_state
|
|
99
|
+
def balance_cmd(state: AppState, as_json: bool) -> None:
|
|
100
|
+
"""Your balance and number of running pods."""
|
|
101
|
+
try:
|
|
102
|
+
bal = state.client().get_balance()
|
|
103
|
+
except ApiError as exc:
|
|
104
|
+
if exc.is_not_found:
|
|
105
|
+
fail("This API server does not expose the balance yet. See it on https://voltagegpu.com/billing")
|
|
106
|
+
raise
|
|
107
|
+
if as_json:
|
|
108
|
+
echo_json(bal.to_dict())
|
|
109
|
+
return
|
|
110
|
+
if bal.balance is None:
|
|
111
|
+
info(f"Balance hidden: {esc(bal.balance_hidden or 'this key cannot read the account balance')}")
|
|
112
|
+
else:
|
|
113
|
+
console.print(f"Balance [bold green]{money(bal.balance)}[/bold green] {esc(bal.currency)}")
|
|
114
|
+
if bal.active_pods is not None:
|
|
115
|
+
info(f"Running {bal.active_pods} pod{'s' if bal.active_pods != 1 else ''}")
|
|
116
|
+
hint(f"Top up: {esc(bal.top_up_url)}")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@click.group("ssh-keys")
|
|
120
|
+
def ssh_keys_group() -> None:
|
|
121
|
+
"""Manage the SSH public keys injected into your pods."""
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@ssh_keys_group.command("list")
|
|
125
|
+
@click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
|
|
126
|
+
@pass_state
|
|
127
|
+
def ssh_keys_list(state: AppState, as_json: bool) -> None:
|
|
128
|
+
"""List your SSH keys."""
|
|
129
|
+
keys = state.client().list_ssh_keys()
|
|
130
|
+
if as_json:
|
|
131
|
+
echo_json([k.to_dict() for k in keys])
|
|
132
|
+
return
|
|
133
|
+
if not keys:
|
|
134
|
+
info("No SSH key yet. Add one: voltagegpu ssh-keys add")
|
|
135
|
+
return
|
|
136
|
+
table("SSH keys", [("KEY ID", {"style": "cyan", "no_wrap": True}), ("NAME",), ("KEY",), ("ADDED",)],
|
|
137
|
+
[(k.id, k.name, k.summary, (k.created_at or "")[:10]) for k in keys])
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@ssh_keys_group.command("add")
|
|
141
|
+
@click.option("--name", help="Label for the key (default: the file name).")
|
|
142
|
+
@click.option("--file", "key_file", type=click.Path(exists=True, dir_okay=False, path_type=Path),
|
|
143
|
+
help="Public key file (default: ~/.ssh/id_ed25519.pub, id_ecdsa.pub or id_rsa.pub).")
|
|
144
|
+
@click.option("--key", "key_text", help="Public key string instead of a file.")
|
|
145
|
+
@click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
|
|
146
|
+
@pass_state
|
|
147
|
+
def ssh_keys_add(state: AppState, name: Optional[str], key_file: Optional[Path], key_text: Optional[str], as_json: bool) -> None:
|
|
148
|
+
"""Register an SSH public key."""
|
|
149
|
+
if key_file and key_text:
|
|
150
|
+
fail("Give --file or --key, not both.", code=2)
|
|
151
|
+
if not key_text:
|
|
152
|
+
path = key_file or default_public_key_file()
|
|
153
|
+
if path is None:
|
|
154
|
+
fail("No public key found in ~/.ssh. Create one with: ssh-keygen -t ed25519", code=2)
|
|
155
|
+
if path.suffix != ".pub" and path.with_suffix(path.suffix + ".pub").exists():
|
|
156
|
+
fail(f"{path} looks like a private key. Use {path}.pub", code=2)
|
|
157
|
+
key_text = path.read_text(encoding="utf-8", errors="replace")
|
|
158
|
+
name = name or path.name
|
|
159
|
+
public_key = read_public_key(key_text)
|
|
160
|
+
key = state.client().add_ssh_key(name or "cli-key", public_key)
|
|
161
|
+
if as_json:
|
|
162
|
+
echo_json(key.to_dict())
|
|
163
|
+
else:
|
|
164
|
+
console.print(f"[green]Added.[/green] {esc(key.name)} ({esc(key.id)})")
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@ssh_keys_group.command("delete")
|
|
168
|
+
@click.argument("key_id")
|
|
169
|
+
@click.option("-y", "--yes", is_flag=True, help="Do not ask for confirmation.")
|
|
170
|
+
@pass_state
|
|
171
|
+
def ssh_keys_delete(state: AppState, key_id: str, yes: bool) -> None:
|
|
172
|
+
"""Delete an SSH key (running pods keep the keys they were created with)."""
|
|
173
|
+
if not yes:
|
|
174
|
+
if not is_interactive():
|
|
175
|
+
fail("Re-run with --yes to confirm in a script.", code=2)
|
|
176
|
+
if not click.confirm(f"Delete SSH key {key_id}?", default=False):
|
|
177
|
+
raise click.exceptions.Exit(1)
|
|
178
|
+
state.client().delete_ssh_key(key_id)
|
|
179
|
+
console.print(f"[green]Deleted.[/green] {esc(key_id)}")
|