This repository was archived by the owner on Jan 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathshell.py
More file actions
47 lines (39 loc) · 1.61 KB
/
shell.py
File metadata and controls
47 lines (39 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sys
from datetime import timedelta
import asyncclick as click
from jumpstarter_cli_common import opt_config
from jumpstarter_cli_common.exceptions import handle_exceptions
from .common import opt_duration_partial, opt_selector
from jumpstarter.common.utils import launch_shell
from jumpstarter.config import ClientConfigV1Alpha1, ExporterConfigV1Alpha1
@click.command("shell")
@opt_config()
# client specific
# TODO: warn if these are specified with exporter config
@click.option("--lease", "lease_name")
@opt_selector
@opt_duration_partial(default=timedelta(minutes=30), show_default="00:30:00")
# end client specific
@handle_exceptions
def shell(config, lease_name, selector, duration):
"""
Spawns a shell connecting to a local or remote exporter
"""
match config:
case ClientConfigV1Alpha1():
exit_code = 0
with config.lease(selector=selector, lease_name=lease_name, duration=duration) as lease:
with lease.serve_unix() as path:
with lease.monitor():
exit_code = launch_shell(
path,
"remote",
config.drivers.allow,
config.drivers.unsafe,
use_alternative_endpoints=config.use_alternative_endpoints,
)
sys.exit(exit_code)
case ExporterConfigV1Alpha1():
with config.serve_unix() as path:
# SAFETY: the exporter config is local thus considered trusted
launch_shell(path, "local", allow=[], unsafe=True)