Skip to content

Commit

Permalink
Put all commands under deployer
Browse files Browse the repository at this point in the history
- No 'debug' subcommand now, we can split these out later if
  necessary
- Update all items in README to use rich formatted output
  • Loading branch information
yuvipanda committed Nov 8, 2022
1 parent 71eb54a commit b646968
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 165 deletions.
316 changes: 165 additions & 151 deletions deployer/README.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions deployer/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Import the various subcommands here, they will be automatically
# registered into the app
import deployer.debug # noqa: F401
import deployer.deployer # noqa: F401

from .cli_app import app


def main():
app()
11 changes: 11 additions & 0 deletions deployer/cli_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Export the typer app we use throughout our codebase.
Having this in a single file allows multiple files to provide subcommands
for the same CLI application. So we can put deployment related stuff under
deployer.py, debug related stuff under debug.py, etc
"""
import typer

# The typer app to which all subcommands are attached
app = typer.Typer()
3 changes: 1 addition & 2 deletions deployer/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
import typer
from ruamel.yaml import YAML

from .cli_app import app
from .cluster import Cluster
from .file_acquisition import find_absolute_path_to_cluster_file

app = typer.Typer()

# Without `pure=True`, I get an exception about str / byte issues
yaml = YAML(typ="safe", pure=True)

Expand Down
11 changes: 3 additions & 8 deletions deployer/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from ruamel.yaml import YAML

from .auth import KeyProvider
from .cli_app import app
from .cluster import Cluster
from .config_validation import (
validate_authenticator_config,
Expand All @@ -39,8 +40,6 @@
yaml = YAML(typ="safe", pure=True)
helm_charts_dir = Path(__file__).parent.parent.joinpath("helm-charts")

app = typer.Typer(help="Deploy many JupyterHubs on many Kubernetes Clusters")


@app.command()
def use_cluster_credentials(
Expand Down Expand Up @@ -244,7 +243,7 @@ def deploy(
@app.command()
def generate_helm_upgrade_jobs(
changed_filepaths: str = typer.Argument(
..., help="Space delimited list of files that have changed"
..., help="Comma delimited list of files that have changed"
)
):
"""
Expand Down Expand Up @@ -466,7 +465,7 @@ def run_hub_health_check(
print_colour("Health check succeeded!")


@app.command
@app.command()
def validate(
cluster_name: str = typer.Argument(..., help="Name of cluster to operate on"),
hub_name: str = typer.Argument(..., help="Name of hub to operate on"),
Expand All @@ -478,7 +477,3 @@ def validate(
validate_support_config(cluster_name)
validate_hub_config(cluster_name, hub_name)
validate_authenticator_config(cluster_name, hub_name)


def main():
app()
2 changes: 1 addition & 1 deletion docs/hub-deployment-guide/hubs/other-hub-ops/delete-hub.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Especially if we think that users will want this information in the future (or i
Delete user home directories using the [deployer `exec-homes-shell`](https://github.com/2i2c-org/infrastructure/blob/master/deployer/README.md#exec-homes-shell) option.

```bash
deployer.debug exec-homes-shell <cluster_name> <hub_name>
deployer exec-homes-shell <cluster_name> <hub_name>
```

This should get you a shell with the home directories of all the users on the given hub. Delete all user home directories with:
Expand Down
4 changes: 2 additions & 2 deletions docs/sre-guide/support/home-dir.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The
subcommand of the deployer can help us here.

```bash
python3 deployer.debug exec-homes-shell <cluster-name> <hub-name>
deployer exec-homes-shell <cluster-name> <hub-name>
```

Will open a bash shell with all the home directories of all the users of `<hub-name>`
Expand All @@ -19,4 +19,4 @@ in `<cluster-name>` mounted in read-write fashion under `/home/`.
BE CAREFUL! DO NOT DELETE THINGS HERE WITHOUT BEING SURE YOU WANT THEM GONE.
If in doubt, **rename files** which will allow the server to start up again and preserve the file for the user so they can correct the file contents.
```
```
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
packages=find_packages(),
entry_points={
"console_scripts": [
"deployer = deployer.deployer:main",
"deployer = deployer.__main__:main",
],
},
)

0 comments on commit b646968

Please sign in to comment.