mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-06-29 06:00:45 +00:00
[ISS-1258][DC] resolving formatting and line length issues
This commit is contained in:
parent
10ce480836
commit
6f0f112e53
2 changed files with 22 additions and 10 deletions
|
|
@ -49,7 +49,14 @@ def get_aws_secrets_from_json_file(json_credentials_file: str) -> set[str]:
|
||||||
return set()
|
return set()
|
||||||
|
|
||||||
keys = set()
|
keys = set()
|
||||||
for var in ('AccessKeyId', 'SecretAccessKey', 'SessionToken', 'aws_secret_access_key', 'aws_security_token', 'aws_session_token'):
|
for var in (
|
||||||
|
'AccessKeyId',
|
||||||
|
'SecretAccessKey',
|
||||||
|
'SessionToken',
|
||||||
|
'aws_secret_access_key',
|
||||||
|
'aws_security_token',
|
||||||
|
'aws_session_token'
|
||||||
|
):
|
||||||
if var in data.get('Credentials', {}):
|
if var in data.get('Credentials', {}):
|
||||||
keys.add(data['Credentials'][var])
|
keys.add(data['Credentials'][var])
|
||||||
return keys
|
return keys
|
||||||
|
|
@ -125,8 +132,8 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--json-credentials-file',
|
'--json-credentials-dir',
|
||||||
dest='json_credential_file_locations',
|
dest='json_credential_dir',
|
||||||
action='append',
|
action='append',
|
||||||
default=['~/.aws/cli/cache/', '~/.aws/login/cache/'],
|
default=['~/.aws/cli/cache/', '~/.aws/login/cache/'],
|
||||||
help=(
|
help=(
|
||||||
|
|
@ -143,13 +150,14 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
credential_files = set(args.credentials_file)
|
credential_files = set(args.credentials_file)
|
||||||
json_credential_file_locations = set(args.json_credential_file_locations)
|
json_credential_dirs = set(args.json_credential_dir)
|
||||||
json_credential_files = set()
|
json_credential_files = set()
|
||||||
for json_credential_file_location in json_credential_file_locations:
|
for json_credential_dir in json_credential_dirs:
|
||||||
if os.path.isdir(os.path.expanduser(json_credential_file_location)):
|
if os.path.isdir(os.path.expanduser(json_credential_dir)):
|
||||||
for filename in os.listdir(os.path.expanduser(json_credential_file_location)):
|
for file in os.listdir(os.path.expanduser(json_credential_dir)):
|
||||||
if filename.endswith('.json'):
|
if file.endswith('.json'):
|
||||||
json_credential_files.add(os.path.join(json_credential_file_location, filename))
|
(json_credential_files
|
||||||
|
.add(os.path.join(json_credential_dir, file)))
|
||||||
|
|
||||||
# Add the credentials files configured via environment variables to the set
|
# Add the credentials files configured via environment variables to the set
|
||||||
# of files to to gather AWS secrets from.
|
# of files to to gather AWS secrets from.
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,11 @@ def test_get_aws_secrets_from_env(env_vars, values):
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
'aws_temp_secrets_file.json',
|
'aws_temp_secrets_file.json',
|
||||||
{"tempAccessKeyId", "tempSecretAccessKey", "tempSessionToken"},
|
{
|
||||||
|
"tempAccessKeyId",
|
||||||
|
"tempSecretAccessKey",
|
||||||
|
"tempSessionToken"
|
||||||
|
},
|
||||||
),
|
),
|
||||||
('nonsense.txt', set()),
|
('nonsense.txt', set()),
|
||||||
('ok_json.json', set()),
|
('ok_json.json', set()),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue