示例#1
0
def get_secrets(quiet):
    """List the secrets"""

    avl_secrets = Secret.list()

    if not avl_secrets:
        click.echo(highlight_text("No secret found !!!\n"))
        return

    if quiet:
        for secret in avl_secrets:
            click.echo(highlight_text(secret["name"]))
        return

    table = PrettyTable()
    table.field_names = ["NAME", "CREATED ON", "LAST UPDATED", "UUID"]

    for secret in avl_secrets:
        creation_time = (
            secret["creation_time"]).strftime("%A, %d. %B %Y %I:%M%p")
        last_update_time = arrow.get(secret["last_update_time"].astimezone(
            datetime.timezone.utc)).humanize()
        table.add_row([
            highlight_text(secret["name"]),
            highlight_text(creation_time),
            highlight_text(last_update_time),
            highlight_text(secret["uuid"]),
        ])

    click.echo(table)
示例#2
0
def get_secrets_names():
    """To find the names stored in db"""

    secrets = Secret.list()
    secret_names = []
    for secret in secrets:
        secret_names.append(secret["name"])

    return secret_names