Add flag to detect-aws-credentials to allow missing keys

In the event that there exists no configuration for AWS credentials and
they are not exported in to the current environment, a flag may be
passed to allow exiting the hook successfully.

Resolves #174

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
This commit is contained in:
Mike Fiedler 2017-02-10 08:26:26 -05:00
parent 20f04626a1
commit 312e721ce9
No known key found for this signature in database
GPG key ID: 5E1134F2FAF158B9
2 changed files with 23 additions and 0 deletions

View file

@ -95,6 +95,12 @@ def main(argv=None):
'secret keys from'
)
)
parser.add_argument(
'--allow-missing-credentials',
dest='allow_missing_credentials',
action='store_true',
help='Allow hook to pass when no credentials are detected.'
)
args = parser.parse_args(argv)
credential_files = set(args.credential_files)
@ -111,6 +117,9 @@ def main(argv=None):
# the set of keys.
keys |= get_aws_secrets_from_env()
if not keys and args.allow_missing_credentials:
return 0
if not keys:
print(
'No AWS keys were found in the configured credential files and '