Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/next-release/enhancement-configure-99484.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "enhancement",
"category": "configure",
"description": "Add fish shell format for export-credentials command (fixes `#9670 <https://github.com/aws/aws-cli/issues/9670>`__)"
}
10 changes: 10 additions & 0 deletions awscli/customizations/configure/exportcreds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -152,6 +161,7 @@ def display_credentials(self, credentials):
BashNoExportEnvFormatter,
PowershellFormatter,
WindowsCmdFormatter,
FishShellFormatter,
]
}

Expand Down
16 changes: 16 additions & 0 deletions tests/unit/customizations/configure/test_exportcreds.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
ConfigureExportCredentialsCommand,
CredentialProcessFormatter,
Credentials,
FishShellFormatter,
PowershellFormatter,
WindowsCmdFormatter,
convert_botocore_credentials,
Expand Down Expand Up @@ -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,
(
Expand Down