Skip to content

Commit 8d155c4

Browse files
committed
Add fish shell format for export-credentials (#9670)
1 parent 238026d commit 8d155c4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

awscli/customizations/configure/exportcreds.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ class WindowsCmdFormatter(BasePerLineFormatter):
117117
_VAR_FORMAT = 'set {var_name}={var_value}'
118118

119119

120+
class FishShellFormatter(BasePerLineFormatter):
121+
FORMAT = 'fish'
122+
DOCUMENTATION = (
123+
'Display credentials as Fish shell environment variables: '
124+
'``set -gx AWS_ACCESS_KEY_ID EXAMPLE``'
125+
)
126+
_VAR_FORMAT = 'set -gx {var_name} {var_value}'
127+
128+
120129
class CredentialProcessFormatter(BaseCredentialFormatter):
121130
FORMAT = 'process'
122131
DOCUMENTATION = (
@@ -152,6 +161,7 @@ def display_credentials(self, credentials):
152161
BashNoExportEnvFormatter,
153162
PowershellFormatter,
154163
WindowsCmdFormatter,
164+
FishShellFormatter,
155165
]
156166
}
157167

tests/unit/customizations/configure/test_exportcreds.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
ConfigureExportCredentialsCommand,
2727
CredentialProcessFormatter,
2828
Credentials,
29+
FishShellFormatter,
2930
PowershellFormatter,
3031
WindowsCmdFormatter,
3132
convert_botocore_credentials,
@@ -109,6 +110,21 @@ def __eq__(self, other):
109110
),
110111
),
111112
),
113+
(
114+
FishShellFormatter,
115+
(
116+
(
117+
'set -gx AWS_ACCESS_KEY_ID access_key\n'
118+
'set -gx AWS_SECRET_ACCESS_KEY secret_key\n'
119+
),
120+
(
121+
'set -gx AWS_ACCESS_KEY_ID access_key\n'
122+
'set -gx AWS_SECRET_ACCESS_KEY secret_key\n'
123+
'set -gx AWS_SESSION_TOKEN token\n'
124+
'set -gx AWS_CREDENTIAL_EXPIRATION 2023-01-01T00:00:00Z\n'
125+
),
126+
),
127+
),
112128
(
113129
CredentialProcessFormatter,
114130
(

0 commit comments

Comments
 (0)