diff --git a/awscli/customizations/configure/exportcreds.py b/awscli/customizations/configure/exportcreds.py index f08b262b2582..32f23d6f2a3c 100644 --- a/awscli/customizations/configure/exportcreds.py +++ b/awscli/customizations/configure/exportcreds.py @@ -117,6 +117,15 @@ class WindowsCmdFormatter(BasePerLineFormatter): _VAR_FORMAT = 'set {var_name}={var_value}' +class FishShellFormatter(BasePerLineFormatter): + FORMAT = 'fish' + DOCUMENTATION = ( + 'Display credentials as Fish shell environment variables: ' + '``set -gx AWS_ACCESS_KEY_ID "EXAMPLE"``' + ) + _VAR_FORMAT = 'set -gx {var_name} "{var_value}"' + + class CredentialProcessFormatter(BaseCredentialFormatter): FORMAT = 'process' DOCUMENTATION = ( @@ -152,6 +161,7 @@ def display_credentials(self, credentials): BashNoExportEnvFormatter, PowershellFormatter, WindowsCmdFormatter, + FishShellFormatter, ] } diff --git a/tests/unit/customizations/configure/test_exportcreds.py b/tests/unit/customizations/configure/test_exportcreds.py index 566ec524366e..53cfa493d65b 100644 --- a/tests/unit/customizations/configure/test_exportcreds.py +++ b/tests/unit/customizations/configure/test_exportcreds.py @@ -26,6 +26,7 @@ ConfigureExportCredentialsCommand, CredentialProcessFormatter, Credentials, + FishShellFormatter, PowershellFormatter, WindowsCmdFormatter, convert_botocore_credentials, @@ -109,6 +110,21 @@ def __eq__(self, other): ), ), ), + ( + FishShellFormatter, + ( + ( + 'set -gx AWS_ACCESS_KEY_ID "access_key"\n' + 'set -gx AWS_SECRET_ACCESS_KEY "secret_key"\n' + ), + ( + 'set -gx AWS_ACCESS_KEY_ID "access_key"\n' + 'set -gx AWS_SECRET_ACCESS_KEY "secret_key"\n' + 'set -gx AWS_SESSION_TOKEN "token"\n' + 'set -gx AWS_CREDENTIAL_EXPIRATION "2023-01-01T00:00:00Z"\n' + ), + ), + ), ( CredentialProcessFormatter, (