2021-11-03 00:12:32 +00:00
|
|
|
from typing import List
|
|
|
|
|
2021-10-21 02:02:38 +00:00
|
|
|
import click
|
|
|
|
|
2021-11-02 16:21:01 +00:00
|
|
|
from .cli import KiwiCommandType, KiwiCommand
|
|
|
|
from .decorators import kiwi_command
|
2021-11-03 00:12:32 +00:00
|
|
|
from ..instance import Instance
|
2021-10-29 11:38:21 +00:00
|
|
|
|
|
|
|
|
2021-10-29 11:59:57 +00:00
|
|
|
@click.option(
|
|
|
|
"-s/-S",
|
|
|
|
"--show/--no-show",
|
2021-11-03 00:12:32 +00:00
|
|
|
help=f"show actual config contents instead",
|
2021-10-29 11:59:57 +00:00
|
|
|
)
|
2021-10-29 11:38:21 +00:00
|
|
|
@kiwi_command(
|
2021-10-22 15:52:46 +00:00
|
|
|
"list",
|
2021-11-03 00:12:32 +00:00
|
|
|
KiwiCommandType.SERVICE,
|
2021-10-22 15:52:46 +00:00
|
|
|
short_help="Inspect a kiwi-scp instance",
|
|
|
|
)
|
2021-11-02 16:21:01 +00:00
|
|
|
class CMD(KiwiCommand):
|
2021-11-03 00:12:32 +00:00
|
|
|
"""List projects in this instance, services inside a project or service(s) inside a project"""
|
|
|
|
|
2021-10-29 11:38:21 +00:00
|
|
|
@classmethod
|
2021-10-29 11:59:57 +00:00
|
|
|
def run_for_instance(cls, instance: Instance, show: bool = None, **kwargs):
|
2021-11-03 00:12:32 +00:00
|
|
|
if show:
|
|
|
|
click.secho(f"Showing config for kiwi-scp instance at '{instance.directory}'.", fg="green", bold=True)
|
|
|
|
click.echo_via_pager(instance.config.kiwi_yml)
|
|
|
|
|
|
|
|
else:
|
|
|
|
click.secho(f"Projects in kiwi-scp instance at '{instance.directory}':", fg="green", bold=True)
|
|
|
|
|
|
|
|
for project in instance.config.projects:
|
|
|
|
click.echo(
|
|
|
|
click.style(" - ", fg="green") +
|
|
|
|
click.style(project.name, fg="blue") +
|
|
|
|
click.style(' (disabled)' if not project.enabled else '', fg="red")
|
|
|
|
)
|
2021-10-29 11:38:21 +00:00
|
|
|
|
|
|
|
@classmethod
|
2021-11-03 00:12:32 +00:00
|
|
|
def run_for_services(cls, instance: Instance, project_name: str, services: List[str], show: bool = None,
|
2021-10-29 11:59:57 +00:00
|
|
|
**kwargs):
|
|
|
|
print(show)
|
2021-10-29 11:38:21 +00:00
|
|
|
print(services)
|