diff --git a/CHANGELOG.md b/CHANGELOG.md index b32f5e9..075d211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.4.0 - create now has --apply to apply the generated manifest to the cluster +- generic templates endpoint for cli ## 0.3.0 diff --git a/krayt/cli/__init__.py b/krayt/cli/__init__.py index d5c6f0c..035a6de 100644 --- a/krayt/cli/__init__.py +++ b/krayt/cli/__init__.py @@ -6,7 +6,7 @@ from typer import Typer app = Typer() -app.add_typer(templates_app, name="templates", no_args_is_help=True) +app.add_typer(templates_app, name="template", no_args_is_help=True) app.add_typer(pod_app, name="pod", no_args_is_help=True) app.command(name="create")(create) app.command(name="c")(create) diff --git a/krayt/cli/templates.py b/krayt/cli/templates.py index 841cd54..7416db6 100644 --- a/krayt/cli/templates.py +++ b/krayt/cli/templates.py @@ -13,7 +13,8 @@ def list(): @app.command() -def base( +def render( + template_name: Optional[str] = typer.Option("base.sh", "--template-name", "-t"), volumes: Optional[List[str]] = typer.Option( None, "--volume", @@ -48,7 +49,6 @@ def base( help="additional hooks to execute at the start of container initialization", ), ): - template_name = "base.sh" template = env.get_template(template_name) rendered = template.render( volumes=volumes, @@ -62,37 +62,37 @@ def base( print(rendered) -@app.command() -def install( - additional_packages: Optional[List[str]] = typer.Option( - ..., "--additional-packages", "-ap" - ), -): - template_name = "install.sh" - template = env.get_template(template_name) - rendered = template.render(additional_packages=additional_packages) - print(rendered) - - -@app.command() -def motd( - volumes: Optional[List[str]] = typer.Option( - None, - "--volume", - ), - pvcs: Optional[List[str]] = typer.Option( - None, - "--pvc", - ), - additional_packages: Optional[List[str]] = typer.Option( - ..., "--additional-packages", "-ap" - ), -): - template_name = "motd.sh" - template = env.get_template(template_name) - rendered = template.render( - volumes=volumes, - pvcs=pvcs, - additional_packages=additional_packages, - ) - print(rendered) +# @app.command() +# def install( +# additional_packages: Optional[List[str]] = typer.Option( +# ..., "--additional-packages", "-ap" +# ), +# ): +# template_name = "install.sh" +# template = env.get_template(template_name) +# rendered = template.render(additional_packages=additional_packages) +# print(rendered) +# +# +# @app.command() +# def motd( +# volumes: Optional[List[str]] = typer.Option( +# None, +# "--volume", +# ), +# pvcs: Optional[List[str]] = typer.Option( +# None, +# "--pvc", +# ), +# additional_packages: Optional[List[str]] = typer.Option( +# ..., "--additional-packages", "-ap" +# ), +# ): +# template_name = "motd.sh" +# template = env.get_template(template_name) +# rendered = template.render( +# volumes=volumes, +# pvcs=pvcs, +# additional_packages=additional_packages, +# ) +# print(rendered)