8000 feat(aws): Support aws-vault as an option instead of named AWS p… (#206) · matchai/spacefish@5e02e3f · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 3, 2021. It is now read-only.

Commit 5e02e3f

Browse files
koukmatchai
authored andcommitted
feat(aws): Support aws-vault as an option instead of named AWS p… (#206)
When using [99designs/aws-vault](https://github.com/99designs/aws-vault) the variable `AWS_VAULT` is set to indicate which profile has been configured in the environment and the AWS_PROFILE environment variable is not set. This commits makes AWS_VAULT override the profile name.
1 parent 5f41d61 commit 5e02e3f

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

docs/Options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ Haskell section is shown only in directories that contain `stack.yaml`.
223223

224224
### Amazon Web Services (AWS) (`aws`)
225225

226-
Shows selected Amazon Web Services profile configured using [`AWS_PROFILE`](http://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html) variable.
226+
Shows selected Amazon Web Services profile configured using [`AWS_VAULT`](https://github.com/99designs/aws-vault) or [`AWS_PROFILE`](http://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html) variable.
227227

228228
| Variable | Default | Meaning |
229229
| :------- | :-----: | ------- |

functions/__sf_section_aws.fish

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,24 @@ function __sf_section_aws -d "Display the selected aws profile"
2525
# Ensure the aws command is available
2626
type -q aws; or return
2727

28-
# Early return if there's no AWS_PROFILE, or it's set to default
29-
if test -z "$AWS_PROFILE" \
30-
-o "$AWS_PROFILE" = "default"
28+
set -l PROFILE_NAME
29+
30+
# if aws-vault is in use, override profile with that
31+
if test -n "$AWS_VAULT"
32+
set PROFILE_NAME "$AWS_VAULT"
33+
else
34+
set PROFILE_NAME "$AWS_PROFILE"
35+
end
36+
37+
# Early return if there's no named profile, or it's set to default
38+
if test -z "$PROFILE_NAME" \
39+
-o "$PROFILE_NAME" = "default"
3140
return
3241
end
3342

3443
__sf_lib_section \
3544
$SPACEFISH_AWS_COLOR \
3645
$SPACEFISH_AWS_PREFIX \
37-
"$SPACEFISH_AWS_SYMBOL""$AWS_PROFILE" \
46+
"$SPACEFISH_AWS_SYMBOL""$PROFILE_NAME" \
3847
$SPACEFISH_AWS_SUFFIX
3948
end

tests/__sf_section_aws.test.fish

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,19 @@ test "doesn't display the section when SPACEFISH_AWS_SHOW is set to \"false\""
8787
set SPACEFISH_AWS_SHOW false
8888
) = (__sf_section_aws)
8989
end
90+
91+
92+
test "Prints section when AWS_VAULT is set"
93+
(
94+
set AWS_VAULT user2
95+
set_color --bold
96+
echo -n "using "
97+
set_color normal
98+
set_color --bold ff8700
99+
echo -n "☁️ user2"
100+
set_color normal
101+
set_color --bold
102+
echo -n " "
103+
set_color normal
104+
) = (__sf_section_aws)
105+
end

0 commit comments

Comments
 (0)
0