-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: deprecate inspect and download feature commands
changed command structure and hierarchy
- Loading branch information
1 parent
96d4f22
commit 82ed823
Showing
31 changed files
with
250 additions
and
272 deletions.
There are no files selected for viewing
This file contains 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 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,33 @@ | ||
import logging | ||
import pathlib | ||
from typing import Optional | ||
|
||
import typer | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
app = typer.Typer(pretty_exceptions_show_locals=False, pretty_exceptions_short=False) | ||
|
||
app.command() | ||
|
||
|
||
@app.command("devcontainer-feature") | ||
def generate_command( | ||
feature_definition: pathlib.Path, | ||
output_dir: pathlib.Path, | ||
release_version: Optional[str] = None | ||
) -> None: | ||
try: | ||
from dcontainer.devcontainer.feature_generation.oci_feature_generator import OCIFeatureGenerator | ||
except ImportError as e: | ||
logger.error( | ||
"Some imports required for feature generation are missing.\nMake sure you have included the generate extras during installation.\n eg. 'pip install2 dcontainer[generate]'" | ||
) | ||
raise typer.Exit(code=1) from e | ||
|
||
OCIFeatureGenerator.generate(feature_definition=feature_definition.as_posix(), | ||
output_dir=output_dir.as_posix(), | ||
release_version=release_version) | ||
|
||
|
This file was deleted.
Oops, something went wrong.
Empty file.
14 changes: 0 additions & 14 deletions
14
dcontainer/cli/inspect/extract_devcontainer_feature_dict.py
This file was deleted.
Oops, something went wrong.
This file contains 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,59 @@ | ||
import logging | ||
from typing import List, Optional, Dict | ||
|
||
import typer | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
app = typer.Typer(pretty_exceptions_show_locals=False, pretty_exceptions_short=False) | ||
|
||
app.command() | ||
|
||
|
||
def _validate_args(value: Optional[List[str]]): | ||
if value is not None: | ||
for arg in value: | ||
splitted_arg = arg.split("=") | ||
if len(splitted_arg) < 2 or len(splitted_arg[0]) == 0: | ||
raise typer.BadParameter("Must be formatted as 'key=value'") | ||
return value | ||
|
||
|
||
@app.command("devcontainer-feature") | ||
def install_devcontainer_feature( | ||
feature: str, | ||
option: Optional[List[str]] = typer.Option(None, callback=_validate_args), | ||
remote_user: Optional[str] = typer.Option(None, callback=_validate_args), | ||
env: Optional[List[str]] = typer.Option(None, callback=_validate_args), | ||
verbose: bool = False, | ||
) -> None: | ||
from dcontainer.devcontainer.oci_feature_installer import OCIFeatureInstaller | ||
|
||
def _key_val_arg_to_dict(args: Optional[List[str]]) -> Dict[str, str]: | ||
if args is None: | ||
return {} | ||
|
||
args_dict = {} | ||
for single_arg in args: | ||
single_arg = _strip_if_wrapped_around(single_arg, '"') | ||
arg_name = single_arg.split("=")[0] | ||
arg_value = single_arg[len(arg_name) + 1:] | ||
arg_value = _strip_if_wrapped_around(arg_value, '"') | ||
args_dict[arg_name] = arg_value | ||
return args_dict | ||
|
||
def _strip_if_wrapped_around(value: str, char: str) -> str: | ||
if len(char) > 1: | ||
raise ValueError( | ||
"For clarity sake, will only strip one character at a time" | ||
) | ||
|
||
if len(value) >= 2 and value[0] == char and value[-1] == char: | ||
return value.strip(char) | ||
return value | ||
|
||
options_dict = _key_val_arg_to_dict(option) | ||
envs_dict = _key_val_arg_to_dict(env) | ||
|
||
OCIFeatureInstaller.install(feature_ref=feature, envs=envs_dict, options=options_dict, remote_user=remote_user, | ||
verbose=verbose) |
Empty file.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions
12
...tainer/cli/generate/dir_models/src_dir.py → .../feature_generation/dir_models/src_dir.py
This file contains 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
6 changes: 3 additions & 3 deletions
6
...ainer/cli/generate/dir_models/test_dir.py → ...feature_generation/dir_models/test_dir.py
This file contains 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
Oops, something went wrong.