Skip to content
This repository was archived by the owner on Sep 18, 2023. It is now read-only.

Commit fc9026d

Browse files
committed
Further clean up code to generate environment variables.
1 parent 5f890f0 commit fc9026d

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

mozilla_aws_cli/login.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ def print_output(self):
425425
if self.output == "envvar":
426426
output_map.update(
427427
{var: self.credentials.get(key)
428-
for key, var in ENV_VARIABLE_NAME_MAP.item()})
429-
output_map["MAWS_PROMPT"] = self.display_name
428+
for key, var in ENV_VARIABLE_NAME_MAP.items()})
430429
elif self.output == "shared":
431430
# Write the credentials
432431
path = write_aws_shared_credentials(
@@ -435,15 +434,12 @@ def print_output(self):
435434
if path:
436435
output_map.update({
437436
"AWS_PROFILE": self.profile_name,
438-
"AWS_SHARED_CREDENTIALS_FILE": path,
439-
"MAWS_PROMPT": self.display_name})
437+
"AWS_SHARED_CREDENTIALS_FILE": path})
440438
elif self.output == "awscli":
441439
# Call into aws a bunch of times
442440
if write_aws_cli_credentials(self.profile_name,
443441
self.credentials):
444-
output_map.update({
445-
"AWS_PROFILE": self.profile_name,
446-
"MAWS_PROMPT": self.display_name})
442+
output_map["AWS_PROFILE"] = self.profile_name
447443
else:
448444
logger.error("Unable to write credentials with aws-cli.")
449445
elif self.output == "boto":
@@ -470,13 +466,12 @@ def print_output(self):
470466
raise ValueError(
471467
"Output setting unknown : {}".format(self.output))
472468

473-
if 'ExpirationSeconds' in self.credentials:
474-
output_map['AWS_SESSION_EXPIRATION'] = self.credentials['ExpirationSeconds']
475-
476469
message = "Environment variables set for role {}".format(
477470
self.role_arn) if self.print_role_arn else None
478471

479-
if output_map and self.print_output_map:
472+
if self.print_output_map:
473+
output_map['AWS_SESSION_EXPIRATION'] = self.credentials.get('ExpirationSeconds')
474+
output_map["MAWS_PROMPT"] = self.display_name
480475
for name in ENV_VARIABLE_NAMES:
481476
output_map.setdefault(name, None)
482477
print(output_set_env_vars(output_map, message))

0 commit comments

Comments
 (0)