diff --git a/docs/source/cli/clients.md b/docs/source/cli/clients.md index 0d5a54480..98354c03e 100644 --- a/docs/source/cli/clients.md +++ b/docs/source/cli/clients.md @@ -79,10 +79,10 @@ self-signed certificates. 3. Those details can be installed as a secret on CI, or passed down to the final user. - Then the user can create the client using the [jmp client](./reference/jmp-client.md#jmp-client-create-config) CLI: + Then the user can create the client using the [jmp client](./reference/jmp-client.md#jmp-client-config-create) CLI: ```bash - $ jmp client create-config my-client + $ jmp client config create my-client Enter a valid Jumpstarter service endpoint: devl.jumpstarter.dev Enter a Jumpstarter auth token (hidden): *** Enter a comma-separated list of allowed driver packages (optional): diff --git a/docs/source/config/cli.md b/docs/source/config/cli.md index c528cbe92..ac9a4cb0d 100644 --- a/docs/source/config/cli.md +++ b/docs/source/config/cli.md @@ -90,30 +90,30 @@ please follow the instructions in the [Jumpstarter service CLI](../cli/clients.m Importing a new client is as simple as copying the administrator provided yaml file to `~/.config/jumpstarter/clients/`, alternatively if we have the token -and endpoint the `jmp client create ` command can be used to create +and endpoint the `jmp client config create ` command can be used to create the config file. -To switch between different client configs, use the `jmp client use-config ` command: +To switch between different client configs, use the `jmp client config use ` command: ```bash -$ jmp client use-config another +$ jmp client config use another Using client config '/home/jdoe/.config/jumpstarter/clients/another.yaml' ``` -All client configurations can be listed with `jmp client list-configs`: +All client configurations can be listed with `jmp client config list`: ```bash -$ jmp client list-configs +$ jmp client config list CURRENT NAME ENDPOINT PATH * default jumpstarter1.my-lab.com:1443 /home/jdoe/.config/jumpstarter/clients/default.yaml myclient jumpstarter2.my-lab.com:1443 /home/jdoe/.config/jumpstarter/clients/myclient.yaml another jumpstarter3.my-lab.com:1443 /home/jdoe/.config/jumpstarter/clients/another.yaml ``` -Clients can also be removed using `jmp client delete-config `: +Clients can also be removed using `jmp client config delete `: ```bash -$ jmp client delete-config myclient +$ jmp client config delete myclient Deleted client config '/home/jdoe/.config/jumpstarter/clients/myclient.yaml' ``` @@ -201,10 +201,10 @@ please follow the instructions in the [Jumpstarter service CLI](../cli/exporters ### Creating a exporter configuration file To create a new exporter configuration file from a know endpoint and -token the `jmp exporter create ` command can be used. +token the `jmp exporter config create ` command can be used. ```bash -$ jmp exporter create myexporter +$ jmp exporter config create myexporter Endpoint: grpc.jumpstarter.my.domain.com Token: <> ``` @@ -222,19 +222,19 @@ The path to a config can also be provided: jmp exporter run -c /etc/jumpstarter/exporters/another/exporter.yaml ``` -All exporter configurations can be listed with `jmp exporter list`: +All exporter configurations can be listed with `jmp exporter config list`: ```bash -$ jmp exporter list +$ jmp exporter config list ALIAS PATH test-exporter-2 /etc/jumpstarter/exporters/test-exporter-2.yaml my-exporter /etc/jumpstarter/exporters/my-exporter.yaml ``` -Exporers can also be removed using `jmp exporter delete `: +Exporers can also be removed using `jmp exporter config delete `: ```bash -$ jmp exporter delete myexporter +$ jmp exporter config delete myexporter Deleted exporter config '/etc/jumpstarter/exporters/myexporter.yaml' ``` diff --git a/docs/source/getting-started/setup-exporter-client.md b/docs/source/getting-started/setup-exporter-client.md index 878a5285b..59dcc1eeb 100644 --- a/docs/source/getting-started/setup-exporter-client.md +++ b/docs/source/getting-started/setup-exporter-client.md @@ -56,7 +56,7 @@ To edit the config file with your default text editor, run the following command ```bash # Opens the config for "testing" in your default editor -$ jmp exporter edit-config testing +$ jmp exporter config edit testing ``` Add the `storage` and `power` drivers under the `export` field in the config file. diff --git a/docs/source/installation/python-package.md b/docs/source/installation/python-package.md index 817c45331..1cc75a25b 100644 --- a/docs/source/installation/python-package.md +++ b/docs/source/installation/python-package.md @@ -88,7 +88,7 @@ $ alias jmp-client='podman run --rm -it -w /home \ Then you can try: ```bash -$ jmp-client list-configs +$ jmp-client config list CURRENT NAME ENDPOINT PATH * default grpc.devel.jumpstarter.dev:443 /root/.config/jumpstarter/clients/default.yaml test grpc.devel.jumpstarter.dev:443 /root/.config/jumpstarter/clients/test.yaml @@ -129,4 +129,4 @@ The Jumpstarter packages which can be installed are: | [`jumpstarter-driver-*`](https://github.com/jumpstarter-dev/jumpstarter/tree/main/packages) | All community and official driver packages that are distributed as part of Jumpstarter are prefixed with `jumpstarter-driver-*`. This includes drivers for PySerial, SD Wire, HTTP, CAN, and more. Driver packages only need to be installed on the exporter/client if they are used by your testing environment. All drivers are optional. | | [`jumpstarter-adapter-*`](https://github.com/jumpstarter-dev/jumpstarter/tree/main/packages) | All community and official adapter packages that are distributed as part of Jumpstarter are prefixed with `jumpstarter-adapter-*`. This includes adapters to redirect streams to local ports, unix sockets, perform ssh connections, etc. | | [`jumpstarter-imagehash`](https://github.com/jumpstarter-dev/jumpstarter/tree/main/packages/jumpstarter-imagehash) | A library to perform image checking from video inputs using the simple python imagehash library | -| [`jumpstarter-testing`](https://github.com/jumpstarter-dev/jumpstarter/tree/main/packages/jumpstarter-testing) | Testing tools for writing Jumpstarter-powered tests with `pytest`.| \ No newline at end of file +| [`jumpstarter-testing`](https://github.com/jumpstarter-dev/jumpstarter/tree/main/packages/jumpstarter-testing) | Testing tools for writing Jumpstarter-powered tests with `pytest`.| diff --git a/packages/jumpstarter-cli-client/jumpstarter_cli_client/__init__.py b/packages/jumpstarter-cli-client/jumpstarter_cli_client/__init__.py index dafa9451f..0c8fef955 100644 --- a/packages/jumpstarter-cli-client/jumpstarter_cli_client/__init__.py +++ b/packages/jumpstarter-cli-client/jumpstarter_cli_client/__init__.py @@ -6,11 +6,11 @@ from jumpstarter_cli_common import AliasedGroup, opt_log_level, version from jumpstarter_cli_common.exceptions import handle_exceptions -from .client_config import create_client_config, delete_client_config, list_client_configs, use_client_config from .client_exporter import list_client_exporters from .client_lease import client_lease from .client_login import client_login from .client_shell import client_shell +from .config import config from jumpstarter.common.utils import env @@ -38,11 +38,8 @@ def cli(): sys.exit(1) -client.add_command(create_client_config) -client.add_command(delete_client_config) -client.add_command(list_client_configs) client.add_command(list_client_exporters) -client.add_command(use_client_config) +client.add_command(config) client.add_command(client_lease) client.add_command(client_login) client.add_command(client_shell) diff --git a/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_exporter.py b/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_exporter.py index 7d9587640..632b6d6d7 100644 --- a/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_exporter.py +++ b/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_exporter.py @@ -20,7 +20,7 @@ def list_client_exporters(name: str | None, labels: list[(str, str)], output: Ou config = UserConfigV1Alpha1.load_or_create().config.current_client if not config: raise click.BadParameter( - "no client specified, and no default client set: specify a client name, or use jmp client use-config ", + "no client specified, and no default client set: specify a client name, or use jmp client config use", param_hint="name", ) diff --git a/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_lease.py b/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_lease.py index 38917b1ba..033ccdeee 100644 --- a/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_lease.py +++ b/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_lease.py @@ -42,7 +42,7 @@ def lease_release(name, lease, all_leases): config = UserConfigV1Alpha1.load_or_create().config.current_client if not config: raise click.BadParameter( - "no client specified, and no default client set: specify a client name, or use jmp client use-config ", + "no client specified, and no default client set: specify a client name, or use jmp client config use", param_hint="name", ) @@ -89,7 +89,7 @@ def lease_request(name, labels): config = UserConfigV1Alpha1.load_or_create().config.current_client if not config: raise click.BadParameter( - "no client specified, and no default client set: specify a client name, or use jmp client use-config ", + "no client specified, and no default client set: specify a client name, or use jmp client config use", param_hint="name", ) lease = config.request_lease(metadata_filter=MetadataFilter(labels=dict(labels))) diff --git a/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py b/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py index a46aa3107..220df6c99 100644 --- a/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py +++ b/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py @@ -24,7 +24,7 @@ def client_shell(name: str, labels, lease_name): config = UserConfigV1Alpha1.load_or_create().config.current_client if not config: raise click.BadParameter( - "no client specified, and no default client set: specify a client name, or use jmp client use-config ", + "no client specified, and no default client set: specify a client name, or use jmp client config use", param_hint="name", ) diff --git a/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_test.py b/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_test.py index 94c123b3c..a04fba630 100644 --- a/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_test.py +++ b/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_test.py @@ -12,7 +12,8 @@ async def test_client(): result = await runner.invoke( client, [ - "create-config", + "config", + "create", "test1", "--namespace", "default", @@ -32,7 +33,8 @@ async def test_client(): result = await runner.invoke( client, [ - "create-config", + "config", + "create", "test1", "--namespace", "default", @@ -51,33 +53,33 @@ async def test_client(): # create client interactively result = await runner.invoke( client, - ["create-config", "test2"], + ["config", "create", "test2"], input="default\ntest2\nexample.org:443\ndummytoken\njumpstarter.*,com.example.*\n", ) assert result.exit_code == 0 # list clients - result = await runner.invoke(client, ["list-configs"]) + result = await runner.invoke(client, ["config", "list"]) assert result.exit_code == 0 assert "* test1 example.com:443" in result.output assert " test2 example.org:443" in result.output # set default client - result = await runner.invoke(client, ["use-config", "test2"]) + result = await runner.invoke(client, ["config", "use", "test2"]) assert result.exit_code == 0 # list clients - result = await runner.invoke(client, ["list-configs"]) + result = await runner.invoke(client, ["config", "list"]) assert result.exit_code == 0 assert " test1 example.com:443" in result.output assert "* test2 example.org:443" in result.output # delete default client - result = await runner.invoke(client, ["delete-config", "test2"]) + result = await runner.invoke(client, ["config", "delete", "test2"]) assert result.exit_code == 0 # list clients - result = await runner.invoke(client, ["list-configs"]) + result = await runner.invoke(client, ["config", "list"]) assert result.exit_code == 0 assert "* test1 example.com:443" in result.output assert "* test2 example.org:443" not in result.output diff --git a/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_config.py b/packages/jumpstarter-cli-client/jumpstarter_cli_client/config.py similarity index 93% rename from packages/jumpstarter-cli-client/jumpstarter_cli_client/client_config.py rename to packages/jumpstarter-cli-client/jumpstarter_cli_client/config.py index 8488c9c3e..a5188de1a 100644 --- a/packages/jumpstarter-cli-client/jumpstarter_cli_client/client_config.py +++ b/packages/jumpstarter-cli-client/jumpstarter_cli_client/config.py @@ -20,7 +20,14 @@ ) -@click.command("create-config", short_help="Create a client config.") +@click.group() +def config(): + """ + Modify jumpstarter client config files + """ + + +@config.command("create", short_help="Create a client config.") @click.argument("alias") @click.option( "--out", @@ -115,7 +122,7 @@ def set_next_client(name: str): user_config.use_client(None) -@click.command("delete-config", short_help="Delete a client config.") +@config.command("delete", short_help="Delete a client config.") @click.argument("name", type=str) @opt_output_path_only @handle_exceptions @@ -127,7 +134,7 @@ def delete_client_config(name: str, output: PathOutputType): click.echo(path) -@click.command("list-configs", short_help="List available client configurations.") +@config.command("list", short_help="List available client configurations.") @opt_output_all @handle_exceptions def list_client_configs(output: OutputType): @@ -161,7 +168,7 @@ def make_row(c: ClientConfigV1Alpha1): click.echo(make_table(columns, rows)) -@click.command("use-config", short_help="Select the current client config.") +@config.command("use", short_help="Select the current client config.") @click.argument("name", type=str) @opt_output_path_only @handle_exceptions diff --git a/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/__init__.py b/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/__init__.py index 464dba112..4c3857bda 100644 --- a/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/__init__.py +++ b/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/__init__.py @@ -4,8 +4,8 @@ import asyncclick as click from jumpstarter_cli_common import AliasedGroup, opt_log_level, version +from .config import config from .exporter import exporter_shell, run_exporter -from .exporter_config import create_exporter_config, delete_exporter_config, edit_exporter_config, list_exporter_configs from .exporter_login import exporter_login @@ -19,10 +19,7 @@ def exporter(log_level: Optional[str]): logging.basicConfig(level=logging.INFO) -exporter.add_command(create_exporter_config) -exporter.add_command(delete_exporter_config) -exporter.add_command(edit_exporter_config) -exporter.add_command(list_exporter_configs) +exporter.add_command(config) exporter.add_command(run_exporter) exporter.add_command(exporter_login) exporter.add_command(exporter_shell) diff --git a/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_config.py b/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/config.py similarity index 93% rename from packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_config.py rename to packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/config.py index 496fa7d17..aefba8047 100644 --- a/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_config.py +++ b/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/config.py @@ -13,7 +13,14 @@ arg_alias = click.argument("alias", default="default") -@click.command("create-config") +@click.group() +def config(): + """ + Modify jumpstarter exporter config files + """ + + +@config.command("create") @click.option("--namespace", prompt=True) @click.option("--name", prompt=True) @click.option("--endpoint", prompt=True) @@ -41,7 +48,7 @@ def create_exporter_config(alias, namespace, name, endpoint, token, output: Path click.echo(path) -@click.command("delete-config") +@config.command("delete") @arg_alias @opt_output_path_only def delete_exporter_config(alias, output: PathOutputType): @@ -55,7 +62,7 @@ def delete_exporter_config(alias, output: PathOutputType): click.echo(path) -@click.command("edit-config") +@config.command("edit") @arg_alias def edit_exporter_config(alias): """Edit an exporter config.""" @@ -66,7 +73,7 @@ def edit_exporter_config(alias): click.edit(filename=config.path) -@click.command("list-configs") +@config.command("list") @opt_output_all def list_exporter_configs(output: OutputType): """List exporter configs.""" diff --git a/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_test.py b/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_test.py index 1f647ea0b..87a6d81d7 100644 --- a/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_test.py +++ b/packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_test.py @@ -12,7 +12,8 @@ async def test_exporter(): result = await runner.invoke( exporter, [ - "create-config", + "config", + "create", "test1", "--namespace", "default", @@ -30,7 +31,8 @@ async def test_exporter(): result = await runner.invoke( exporter, [ - "create-config", + "config", + "create", "test1", "--namespace", "default", @@ -46,22 +48,22 @@ async def test_exporter(): # create exporter interactively result = await runner.invoke( - exporter, ["create-config", "test2"], input="default\ntest2\nexample.org:443\ndummytoken\n" + exporter, ["config", "create", "test2"], input="default\ntest2\nexample.org:443\ndummytoken\n" ) assert result.exit_code == 0 # list exporters - result = await runner.invoke(exporter, ["list-configs"]) + result = await runner.invoke(exporter, ["config", "list"]) assert result.exit_code == 0 assert "test1" in result.output assert "test2" in result.output # delete exporter - result = await runner.invoke(exporter, ["delete-config", "test2"]) + result = await runner.invoke(exporter, ["config", "delete", "test2"]) assert result.exit_code == 0 ## list exporters - result = await runner.invoke(exporter, ["list-configs"]) + result = await runner.invoke(exporter, ["config", "list"]) assert result.exit_code == 0 assert "test1" in result.output assert "test2" not in result.output