Fix an issue retrieving some types of 1Password items. (#47213)

* Some types of 1Password items have a 'password' field alongside the 'fields' attribute, not inside it, so we need to search there as well.

* Add changelog fragement for onepassword_facts PR #47213.
pull/49562/head
Ryan Conway 6 years ago committed by Sam Doran
parent dd004321d4
commit aacd22acc6

@ -0,0 +1,2 @@
bugfixes:
- onepassword_facts - Fix an issue looking up some 1Password items which have a 'password' attribute alongside the 'fields' attribute, not inside it.

@ -192,6 +192,14 @@ class OnePasswordFacts(object):
else: else:
# This is not a document, let's try to find the requested field # This is not a document, let's try to find the requested field
# Some types of 1Password items have a 'password' field directly alongside the 'fields' attribute,
# not inside it, so we need to check there first.
if (field_name in data['details']):
return {field_name: data['details'][field_name]}
# Otherwise we continue looking inside the 'fields' attribute for the specified field.
else:
if section_title is None: if section_title is None:
for field_data in data['details'].get('fields', []): for field_data in data['details'].get('fields', []):
if field_data.get('name').lower() == field_name.lower(): if field_data.get('name').lower() == field_name.lower():

Loading…
Cancel
Save