fix(aws): override default region if AWS_REGION is set

Co-authored-by: Evgenii Morozov <emorozov@goodgamestudios.com>
This commit is contained in:
Evgeny Morozov 2021-08-04 20:46:59 +02:00 committed by GitHub
parent f83fb24087
commit 84183b7506
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -36,7 +36,7 @@ func (a *aws) enabled() bool {
if !displayDefaultUser && a.Profile == defaultUser { if !displayDefaultUser && a.Profile == defaultUser {
return false return false
} }
a.Region = getEnvFirstMatch("AWS_DEFAULT_REGION", "AWS_REGION") a.Region = getEnvFirstMatch("AWS_REGION", "AWS_DEFAULT_REGION")
if a.Profile != "" && a.Region != "" { if a.Profile != "" && a.Region != "" {
return true return true
} }

View file

@ -25,7 +25,8 @@ func TestAWSSegment(t *testing.T) {
{Case: "enabled with default user", ExpectedString: "default@eu-west", Profile: "default", Region: "eu-west", ExpectedEnabled: true, DisplayDefault: true}, {Case: "enabled with default user", ExpectedString: "default@eu-west", Profile: "default", Region: "eu-west", ExpectedEnabled: true, DisplayDefault: true},
{Case: "disabled with default user", ExpectedString: "default", Profile: "default", Region: "eu-west", ExpectedEnabled: false, DisplayDefault: false}, {Case: "disabled with default user", ExpectedString: "default", Profile: "default", Region: "eu-west", ExpectedEnabled: false, DisplayDefault: false},
{Case: "enabled no region", ExpectedString: "company", ExpectedEnabled: true, Profile: "company"}, {Case: "enabled no region", ExpectedString: "company", ExpectedEnabled: true, Profile: "company"},
{Case: "enabled with region", ExpectedString: "company@eu-west", ExpectedEnabled: true, Profile: "company", Region: "eu-west"}, {Case: "enabled with region", ExpectedString: "company@eu-west", ExpectedEnabled: true, Profile: "company", Region: "eu-west", DefaultRegion: "us-west"},
{Case: "enabled with default region", ExpectedString: "company@us-west", ExpectedEnabled: true, Profile: "company", DefaultRegion: "us-west"},
{ {
Case: "template: enabled no region", Case: "template: enabled no region",
ExpectedString: "profile: company", ExpectedString: "profile: company",