mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 20:01:25 -07:00
onepassword_doc: fix 1Password Connect support (#9625)
Fix 1Password Connect support for onepassword_doc.
This commit is contained in:
parent
1f92a69992
commit
4e0de41a85
3 changed files with 8 additions and 19 deletions
|
@ -46,28 +46,13 @@ RETURN = """
|
|||
"""
|
||||
|
||||
from ansible_collections.community.general.plugins.lookup.onepassword import OnePass, OnePassCLIv2
|
||||
from ansible.errors import AnsibleLookupError
|
||||
from ansible.module_utils.common.text.converters import to_bytes
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
|
||||
|
||||
class OnePassCLIv2Doc(OnePassCLIv2):
|
||||
def get_raw(self, item_id, vault=None, token=None):
|
||||
args = ["document", "get", item_id]
|
||||
if vault is not None:
|
||||
args = [*args, f"--vault={vault}"]
|
||||
|
||||
if self.service_account_token:
|
||||
if vault is None:
|
||||
raise AnsibleLookupError("'vault' is required with 'service_account_token'")
|
||||
|
||||
environment_update = {"OP_SERVICE_ACCOUNT_TOKEN": self.service_account_token}
|
||||
return self._run(args, environment_update=environment_update)
|
||||
|
||||
if token is not None:
|
||||
args = [*args, to_bytes("--session=") + token]
|
||||
|
||||
return self._run(args)
|
||||
return self._add_parameters_and_run(args, vault=vault, token=token)
|
||||
|
||||
|
||||
class LookupModule(LookupBase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue