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 20
kubectl style cli #338
Merged
Merged
kubectl style cli #338
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d0a307a
Fully implement kubectl style commands on client cli
NickCao e662215
Implement custom DURATION type
NickCao 8571722
Dedup client config handling
NickCao 846f286
Dedup opt_selector
NickCao 660a92d
Fix broken jmp admin get leases command with updated CRDs
kirkbrauer fa18287
Fix tests broken by updated CRDs
kirkbrauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
packages/jumpstarter-cli-client/jumpstarter_cli_client/client_exporter.py
This file was deleted.
Oops, something went wrong.
96 changes: 0 additions & 96 deletions
96
packages/jumpstarter-cli-client/jumpstarter_cli_client/client_lease.py
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/jumpstarter-cli-client/jumpstarter_cli_client/common.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| from datetime import timedelta | ||
|
|
||
| import asyncclick as click | ||
| from pydantic import TypeAdapter | ||
|
|
||
| from jumpstarter.config import ( | ||
| ClientConfigV1Alpha1, | ||
| UserConfigV1Alpha1, | ||
| ) | ||
|
|
||
| opt_selector = click.option( | ||
| "-l", | ||
| "--selector", | ||
| help="Selector (label query) to filter on, supports '=', '==', and '!=' (e.g. -l key1=value1,key2=value2)." | ||
| " Matching objects must satisfy all of the specified label constraints.", | ||
| ) | ||
|
|
||
| opt_selector_simple = click.option( | ||
| "-l", | ||
| "--selector", | ||
| help="Selector (label query) to filter on, only supports '=', (e.g. -l key1=value1,key2=value2)." | ||
| " Matching objects must satisfy all of the specified label constraints.", | ||
| required=True, | ||
| ) | ||
|
|
||
|
|
||
| def selector_to_labels(selector: str): | ||
| # TODO: support complex selectors (e.g. !=) | ||
| return dict([term.split("=") for term in selector.split(",")]) | ||
|
|
||
|
|
||
| class ClientParamType(click.ParamType): | ||
| name = "client" | ||
|
|
||
| def convert(self, value, param, ctx): | ||
| if isinstance(value, ClientConfigV1Alpha1): | ||
| return value | ||
|
|
||
| if isinstance(value, bool): # hack to allow loading the default config | ||
| config = UserConfigV1Alpha1.load_or_create().config.current_client | ||
| if config is None: | ||
| self.fail("no client config specified, and no default client config set", param, ctx) | ||
| return config | ||
NickCao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| else: | ||
| return ClientConfigV1Alpha1.load(value) | ||
|
|
||
|
|
||
| class DurationParamType(click.ParamType): | ||
| name = "duration" | ||
|
|
||
| def convert(self, value, param, ctx): | ||
| if isinstance(value, timedelta): | ||
| return value | ||
|
|
||
| try: | ||
| return TypeAdapter(timedelta).validate_python(value) | ||
| except ValueError: | ||
| self.fail(f"{value!r} is not a valid duration", param, ctx) | ||
|
|
||
|
|
||
| DURATION = DurationParamType() | ||
| CLIENT = ClientParamType() | ||
|
|
||
| opt_config = click.option("--client", "config", type=CLIENT, default=False, help="Name of client config") | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.