-
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.
Merge pull request #1661 from alan-turing-institute/pydantic
Use Pydantic for validation and serialisation
- Loading branch information
Showing
50 changed files
with
1,750 additions
and
1,252 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
from .admin import admin_command_group | ||
from .config import config_command_group | ||
from .context import context_command_group | ||
from .deploy import deploy_command_group | ||
from .teardown import teardown_command_group | ||
|
||
__all__ = [ | ||
"admin_command_group", | ||
"context_command_group", | ||
"config_command_group", | ||
"deploy_command_group", | ||
"teardown_command_group", | ||
] |
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"""Command group and entrypoints for managing DSH configuration""" | ||
from pathlib import Path | ||
from typing import Annotated, Optional | ||
|
||
import typer | ||
from rich import print | ||
|
||
from data_safe_haven.config import Config, ContextSettings | ||
|
||
config_command_group = typer.Typer() | ||
|
||
|
||
@config_command_group.command() | ||
def template( | ||
file: Annotated[ | ||
Optional[Path], # noqa: UP007 | ||
typer.Option(help="File path to write configuration template to."), | ||
] = None | ||
) -> None: | ||
"""Write a template Data Safe Haven configuration.""" | ||
context = ContextSettings.from_file().assert_context() | ||
config = Config.template(context) | ||
if file: | ||
with open(file, "w") as outfile: | ||
outfile.write(config.to_yaml()) | ||
else: | ||
print(config.to_yaml()) | ||
|
||
|
||
@config_command_group.command() | ||
def upload( | ||
file: Annotated[Path, typer.Argument(help="Path to configuration file")] | ||
) -> None: | ||
"""Upload a configuration to the Data Safe Haven context""" | ||
context = ContextSettings.from_file().assert_context() | ||
with open(file) as config_file: | ||
config_yaml = config_file.read() | ||
config = Config.from_yaml(context, config_yaml) | ||
config.upload() | ||
|
||
|
||
@config_command_group.command() | ||
def show() -> None: | ||
"""Print the configuration for the selected Data Safe Haven context""" | ||
context = ContextSettings.from_file().assert_context() | ||
config = Config.from_remote(context) | ||
print(config.to_yaml()) |
Oops, something went wrong.