Skip to content

Commit

Permalink
fix crash due to go variable context change
Browse files Browse the repository at this point in the history
Go v1.22 changes how variables are shadowed which was causing
ListAccounts() to return an empty list
  • Loading branch information
synfinatic committed Sep 21, 2024
1 parent 60c56c4 commit 8687d9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Run Wizard",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/aws-sso/",
"args": ["setup", "wizard", "--config=foo.yaml", "--hostname=synfinatic", "--region=us-east-2", "--profile-format=Friendly"]
},
{
"name": "List Profiles",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/aws-sso/",
"args": ["list", "--config=${workspaceFolder}/config.yaml"]
},

{
"name": "Run ECS Server",
"type": "go",
Expand Down
4 changes: 2 additions & 2 deletions internal/sso/awssso.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ func (as *AWSSSO) ListAccounts(input *sso.ListAccountsInput) (*sso.ListAccountsO
as.rolesLock.Lock()
log.Error("AccessToken Unauthorized Error; refreshing", "error", err.Error())

if err = as.reauthenticate(); err != nil {
if err2 := as.reauthenticate(); err2 != nil {

Check warning on line 242 in internal/sso/awssso.go

View check run for this annotation

Codecov / codecov/patch

internal/sso/awssso.go#L242

Added line #L242 was not covered by tests
// fail hard now
return output, err
return output, err2

Check warning on line 244 in internal/sso/awssso.go

View check run for this annotation

Codecov / codecov/patch

internal/sso/awssso.go#L244

Added line #L244 was not covered by tests
}
input.AccessToken = aws.String(as.Token.AccessToken)
as.rolesLock.Unlock()
Expand Down

0 comments on commit 8687d9e

Please sign in to comment.