diff --git a/go.mod b/go.mod index 9421406..de31ec1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/axiomhq/cli -go 1.21 +go 1.22 require ( github.com/AlecAivazis/survey/v2 v2.3.7 diff --git a/internal/cmd/auth/auth_status.go b/internal/cmd/auth/auth_status.go index 7061040..b0fda4b 100644 --- a/internal/cmd/auth/auth_status.go +++ b/internal/cmd/auth/auth_status.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "strings" + "sync" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" @@ -67,14 +68,14 @@ func runStatus(ctx context.Context, opts *statusOptions) error { defer stop() var ( - cs = opts.IO.ColorScheme() - statusInfo = map[string][]string{} + cs = opts.IO.ColorScheme() + statusInfo = map[string][]string{} + statusInfoMu = new(sync.Mutex) // We don't care about the context here. If an errors occurs, still try // to get the status of the other deployments. eg, _ = errgroup.WithContext(ctx) ) for _, deploymentAlias := range deploymentAliases { - deploymentAlias := deploymentAlias deployment, ok := opts.Config.Deployments[deploymentAlias] if !ok { continue @@ -83,6 +84,9 @@ func runStatus(ctx context.Context, opts *statusOptions) error { eg.Go(func() error { var info string defer func() { + statusInfoMu.Lock() + defer statusInfoMu.Unlock() + statusInfo[deploymentAlias] = append(statusInfo[deploymentAlias], info) }()