Allow the use of paths like ~/.project.json (#16064)

* Allow the use of paths like ~/.project.json

This makes it easy to manage credentials files outside of the repo
(and/or user specific credentials).

* Fix format string to log credentials_file.
This commit is contained in:
jayme-github 2017-01-16 15:10:16 +01:00 committed by Brian Coca
parent 2c197343f3
commit f813a8474b
2 changed files with 4 additions and 4 deletions

View file

@ -240,11 +240,11 @@ def _validate_credentials_file(module, credentials_file, require_valid_json=True
'Upgrade to libcloud>=0.17.0.')
return True
except IOError as e:
module.fail_json(msg='GCP Credentials File %s not found.', changed=False)
module.fail_json(msg='GCP Credentials File %s not found.' % credentials_file, changed=False)
return False
except ValueError as e:
if require_valid_json:
module.fail_json(msg='GCP Credentials File %s invalid. Must be valid JSON.', changed=False)
module.fail_json(msg='GCP Credentials File %s invalid. Must be valid JSON.' % credentials_file, changed=False)
else:
display.deprecated(msg=("Non-JSON credentials file provided. This format is deprecated. "
" Please generate a new JSON key from the Google Cloud console"),

View file

@ -637,8 +637,8 @@ def main():
zone = dict(default='us-central1-a'),
service_account_email = dict(),
service_account_permissions = dict(type='list'),
pem_file = dict(),
credentials_file = dict(),
pem_file = dict(type='path'),
credentials_file = dict(type='path'),
project_id = dict(),
ip_forward = dict(type='bool', default=False),
external_ip=dict(default='ephemeral'),