generic templates endpoint for cli

This commit is contained in:
Waylon S. Walker 2025-04-21 09:46:03 -05:00
parent 7daa9a3874
commit 3ce69baf26
3 changed files with 38 additions and 37 deletions

View file

@ -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

View file

@ -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)

View file

@ -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)