mirror of
https://github.com/famedly/ansible-collection-base
synced 2024-09-19 22:01:58 +00:00
chore(gpg_secretstore): fix lints
This commit is contained in:
parent
b4c259dd1d
commit
77a823859f
2 changed files with 23 additions and 12 deletions
|
@ -163,12 +163,16 @@ class SecretStore:
|
|||
recipient_subkeys = self.__gpg.get_recipients(f.read())
|
||||
for recipient_subkey in recipient_subkeys:
|
||||
found_keys = self.__gpg.list_keys(keys=recipient_subkey)
|
||||
if found_keys and found_keys.fingerprints and len(found_keys.fingerprints) > 0:
|
||||
recipients.append(
|
||||
found_keys.fingerprints[0]
|
||||
)
|
||||
if (
|
||||
found_keys
|
||||
and found_keys.fingerprints
|
||||
and len(found_keys.fingerprints) > 0
|
||||
):
|
||||
recipients.append(found_keys.fingerprints[0])
|
||||
else:
|
||||
raise GPGException(f"Can not find primary key in keyring for encryption subkey {recipient_subkey}")
|
||||
raise GPGException(
|
||||
f"Can not find primary key in keyring for encryption subkey {recipient_subkey}"
|
||||
)
|
||||
return recipients
|
||||
except FileNotFoundError:
|
||||
raise FileNotFoundError
|
||||
|
@ -232,7 +236,9 @@ class SecretStore:
|
|||
while base_path.as_posix() != "/":
|
||||
if os.path.isfile(base_path / self.pass_gpg_id_file):
|
||||
break
|
||||
print(f"debug: no {self.pass_gpg_id_file} file found on {base_path}, traversing up")
|
||||
# This is not the proper way to do it, but the proper way is extremely complicated
|
||||
# because we are in module_utils and not a module
|
||||
# print(f"debug: no {self.pass_gpg_id_file} file found on {base_path}, traversing up")
|
||||
base_path = base_path.parent
|
||||
else:
|
||||
raise FileNotFoundError(
|
||||
|
|
|
@ -179,7 +179,7 @@ message:
|
|||
returned: changed
|
||||
warning:
|
||||
description: Human-readable warnings that accrued during the task
|
||||
type: str[]
|
||||
type: list
|
||||
returned: failed or successful but with warnings
|
||||
"""
|
||||
|
||||
|
@ -364,7 +364,12 @@ def main():
|
|||
errors.append(missing_required_lib(lib))
|
||||
traceback.append(str(exception))
|
||||
if errors:
|
||||
module.fail_json(warning=',\n'.join(warnings), errors=errors, traceback="\n".join(traceback), msg=',\n'.join(warnings))
|
||||
module.fail_json(
|
||||
warning=",\n".join(warnings),
|
||||
errors=errors,
|
||||
traceback="\n".join(traceback),
|
||||
msg=",\n".join(warnings),
|
||||
)
|
||||
|
||||
store = SecretStore(
|
||||
password_store_path=module.params["password_store_path"],
|
||||
|
@ -419,9 +424,9 @@ def main():
|
|||
)
|
||||
result["changed"] = False
|
||||
else:
|
||||
result[
|
||||
"message"
|
||||
] = "Secret rotation requested: rotating, if possible."
|
||||
result["message"] = (
|
||||
"Secret rotation requested: rotating, if possible."
|
||||
)
|
||||
result["secret"] = secretGenerator.getSecretData()
|
||||
result["action"] = "update"
|
||||
result["changed"] = True
|
||||
|
@ -495,7 +500,7 @@ def main():
|
|||
|
||||
if result["warning"]:
|
||||
for warn_msg in result["warning"]:
|
||||
module.warn(warn_msg)
|
||||
module.warn(warn_msg)
|
||||
|
||||
result["diff"]["before"] = "\n".join(result["diff"]["before"]) + "\n"
|
||||
result["diff"]["after"] = "\n".join(result["diff"]["after"]) + "\n"
|
||||
|
|
Loading…
Reference in a new issue