mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-04 18:00:26 -07:00
Merge pull request #634 from kuisathaverat/fix/support_more_than_10_versions
fix: support more than 10 secrets versions on gcp_secret_manager
This commit is contained in:
commit
d2aaad7212
2 changed files with 8 additions and 2 deletions
|
@ -208,7 +208,10 @@ class LookupModule(LookupBase):
|
|||
self.raise_error(module, f"unable to list versions of secret {response.status_code}")
|
||||
version_list = response.json()
|
||||
if "versions" in version_list:
|
||||
return sorted(version_list['versions'], key=lambda d: d['name'])[-1]['name'].split('/')[-1]
|
||||
versions_numbers = []
|
||||
for version in version_list['versions']:
|
||||
versions_numbers.append(version['name'].split('/')[-1])
|
||||
return sorted(versions_numbers, key=int)[-1]
|
||||
else:
|
||||
self.raise_error(module, f"Unable to list secret versions via {response.request.url}: {response.json()}")
|
||||
|
||||
|
|
|
@ -261,7 +261,10 @@ def fetch_resource(module, allow_not_found=True):
|
|||
return None
|
||||
|
||||
if "versions" in version_list:
|
||||
latest_version = sorted(version_list['versions'], key=lambda d: d['name'])[-1]['name'].split('/')[-1]
|
||||
versions_numbers = []
|
||||
for version in version_list['versions']:
|
||||
versions_numbers.append(version['name'].split('/')[-1])
|
||||
latest_version = sorted(versions_numbers, key=int)[-1]
|
||||
module.params['calc_version'] = latest_version
|
||||
else:
|
||||
# if this occurs, there are no available secret versions
|
||||
|
|
Loading…
Add table
Reference in a new issue