mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 03:00:23 -07:00
[PR #6720/6bff57ee backport][stable-7] Fix multiple issues with the TSS lookup plugin when using fetch_attachments (#6751)
Fix multiple issues with the TSS lookup plugin when using fetch_attachments (#6720) * Treat files as binary when downloading attachments * Raise a warning when the attachment can't be read * Set the 'itemValue' for files, even when they can't be read * Always return the original secret content * Add changelog * Fix changelog * Update changelog Co-authored-by: Felix Fontein <felix@fontein.de> * Revert "Always return the original secret content" This reverts commita9fb96e165
. --------- Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit6bff57ee6e
) Co-authored-by: laszlojau <49835454+laszlojau@users.noreply.github.com>
This commit is contained in:
parent
ba559d24cd
commit
50eb0a95de
2 changed files with 9 additions and 3 deletions
2
changelogs/fragments/6720-tss-fix-fetch-attachments.yml
Normal file
2
changelogs/fragments/6720-tss-fix-fetch-attachments.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- "tss lookup plugin - fix multiple issues when using ``fetch_attachments=true`` (https://github.com/ansible-collections/community.general/pull/6720)."
|
|
@ -289,11 +289,15 @@ class TSSClient(object):
|
||||||
if file_download_path and os.path.isdir(file_download_path):
|
if file_download_path and os.path.isdir(file_download_path):
|
||||||
if i['isFile']:
|
if i['isFile']:
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(file_download_path, str(obj['id']) + "_" + i['slug']), "w") as f:
|
file_content = i['itemValue'].content
|
||||||
f.write(i['itemValue'].text)
|
with open(os.path.join(file_download_path, str(obj['id']) + "_" + i['slug']), "wb") as f:
|
||||||
i['itemValue'] = "*** Not Valid For Display ***"
|
f.write(file_content)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise AnsibleOptionsError("Failed to download {0}".format(str(i['slug'])))
|
raise AnsibleOptionsError("Failed to download {0}".format(str(i['slug'])))
|
||||||
|
except AttributeError:
|
||||||
|
display.warning("Could not read file content for {0}".format(str(i['slug'])))
|
||||||
|
finally:
|
||||||
|
i['itemValue'] = "*** Not Valid For Display ***"
|
||||||
else:
|
else:
|
||||||
raise AnsibleOptionsError("File download path does not exist")
|
raise AnsibleOptionsError("File download path does not exist")
|
||||||
return obj
|
return obj
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue