fix(aws): hide default when not set

relates to #380
This commit is contained in:
Jan De Dobbeleer 2021-03-08 21:01:28 +01:00 committed by Jan De Dobbeleer
parent 6ee998af15
commit 5055dfc84a
2 changed files with 3 additions and 1 deletions

View file

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

View file

@ -19,6 +19,8 @@ func TestAWSSegment(t *testing.T) {
Template string
DisplayDefault bool
}{
{Case: "enabled with default user", ExpectedString: "default@eu-west", Region: "eu-west", ExpectedEnabled: true, DisplayDefault: true},
{Case: "disabled with default user", ExpectedString: "default@eu-west", Region: "eu-west", ExpectedEnabled: false, DisplayDefault: false},
{Case: "disabled", ExpectedString: "", ExpectedEnabled: false},
{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},