Esempio n. 1
0
def delete_secret(name):
    """Deletes the secret"""

    secrets = get_secrets_names()
    if name not in secrets:
        LOG.error("Secret {} not present !!!".format(name))
        return

    LOG.info("Deleting secret {}".format(name))
    Secret.delete(name)
Esempio n. 2
0
def update_secret(name, value):
    """Updates the secret"""

    secrets = get_secrets_names()
    if name not in secrets:
        LOG.error("Secret {} not present !!!".format(name))
        return

    LOG.info("Updating secret {}".format(name))
    Secret.update(name, value)
Esempio n. 3
0
def update_secret(name, value):
    """Updates the secret"""

    secrets = get_secrets_names()
    if name not in secrets:
        click.echo(highlight_text("\nSecret not present !!!\n"))
        return

    Secret.update(name, value)
    click.echo(highlight_text("\nSecret updated !!!\n"))
Esempio n. 4
0
def delete_secret(name):
    """Deletes the secret"""

    secrets = get_secrets_names()
    if name not in secrets:
        click.echo(highlight_text("\nSecret not present !!!\n"))
        return

    Secret.delete(name)
    click.echo(highlight_text("\nSecret deleted !!!\n"))
Esempio n. 5
0
def create_secret(name, value):
    """Creates the secret"""

    secrets = get_secrets_names()
    if name in secrets:
        LOG.error("Secret {} already present !!!".format(name))
        return

    LOG.debug("Creating secret {}".format(name))
    Secret.create(name, value)
    LOG.info(highlight_text("Secret {} created".format(name)))
Esempio n. 6
0
def create_secret(name, value):
    """Creates the secret"""

    secrets = get_secrets_names()
    if name in secrets:
        click.echo(
            highlight_text("\nSecret Already present !!!\nTry to update secret\n")
        )
        return

    Secret.create(name, value)
    click.echo(highlight_text("\nSecret created !!! \n"))
Esempio n. 7
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)
Esempio n. 8
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
Esempio n. 9
0
def find_secret(name, pass_phrase=""):
    """Gives you the value stored correponding to secret"""

    secret_val = Secret.find(name, pass_phrase)
    return secret_val
Esempio n. 10
0
def clear_secrets():
    """Delete all the secrets"""

    LOG.info("Clearing the secrets")
    Secret.clear()
Esempio n. 11
0
def clear_secrets():
    """Delete all the secrets"""

    Secret.clear()