mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Fix digital_ocean module_util api_token bug (#28924)
* Fix digital_ocean module_util api_token bug * Included environment variables also * Removed try/catch and added a check on self.oauth_token Modules using the DigitalOceanHelper would expect the module to handle any api key resolution.
This commit is contained in:
@@ -92,11 +92,10 @@ class DigitalOceanHelper:
|
|||||||
return self.send('DELETE', path, data)
|
return self.send('DELETE', path, data)
|
||||||
|
|
||||||
def get_do_oauth_token(self):
|
def get_do_oauth_token(self):
|
||||||
try:
|
self.oauth_token = self.module.params.get('oauth_token') or \
|
||||||
self.oauth_token = self.module.params['oauth_token'] or \
|
self.module.params.get('api_token') or \
|
||||||
self.module.params['api_token'] or \
|
os.environ.get('DO_API_TOKEN') or \
|
||||||
os.environ['DO_API_TOKEN'] or \
|
os.environ.get('DO_API_KEY') or \
|
||||||
os.environ['DO_API_KEY'] or \
|
os.environ.get('OAUTH_TOKEN')
|
||||||
os.environ['OAUTH_TOKEN']
|
if self.oauth_token is None:
|
||||||
except KeyError as e:
|
self.module.fail_json(msg='Unable to load api key: oauth_token')
|
||||||
self.module.fail_json(msg='Unable to load %s' % e.message)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user