forked from moritz/alakazam
feat: parse json output of abra app secret ls
This commit is contained in:
@ -455,8 +455,8 @@ def generate_all_secrets(domain: str) -> None:
|
||||
Returns:
|
||||
None: This function outputs directly to the console the results of the secrets generation process.
|
||||
"""
|
||||
stored_secrets = abra("app", "secret", "ls", domain).splitlines()
|
||||
if any("false" in line for line in stored_secrets):
|
||||
stored_secrets = abra("app", "secret", "ls", domain, machine_output=True)
|
||||
if not all(map(lambda x: x['created on server'], stored_secrets)):
|
||||
logging.info(f"Generate all secrets for {domain}")
|
||||
generated_secrets = abra("app", "secret", "generate", "-a", domain)
|
||||
print(f"secrets for {domain} generated")
|
||||
@ -646,11 +646,10 @@ def insert_secret(domain: str, secret_name: str, secret: str) -> None:
|
||||
secret_name (str): The name of the secret to insert.
|
||||
secret (str): The value of the secret to be inserted.
|
||||
"""
|
||||
# TODO parse json
|
||||
stored_secrets = abra("app", "secret", "ls", "-C", domain).splitlines()
|
||||
stored_secrets = abra("app", "secret", "ls", domain, machine_output=True)
|
||||
# Fix extra quotes around secrets
|
||||
secret = unquote_strings(secret)
|
||||
if not any(secret_name in line and "true" in line for line in stored_secrets):
|
||||
if not any(map(lambda x: x['created on server'] and secret_name in x['name'], stored_secrets)):
|
||||
logging.debug(f"Insert secret {secret_name}: {secret} into {domain}")
|
||||
abra("app", "secret", "insert", domain, secret_name, "v1", secret)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user