@@ -5,14 +5,13 @@ import (
55 "fmt"
66 "os"
77 "strings"
8- "sync"
98
109 "github.com/go-errors/errors"
1110 "github.com/spf13/afero"
12- "github.com/spf13/viper"
1311 "github.com/supabase/cli/internal/utils"
1412 "github.com/supabase/cli/internal/utils/flags"
1513 "github.com/supabase/cli/internal/utils/tenant"
14+ "github.com/supabase/cli/pkg/queue"
1615)
1716
1817func Run (ctx context.Context , fsys afero.Fs ) error {
@@ -77,39 +76,53 @@ func CheckVersions(ctx context.Context, fsys afero.Fs) []imageVersion {
7776}
7877
7978func listRemoteImages (ctx context.Context , projectRef string ) map [string ]string {
80- linked := make (map [string ]string , 4 )
81- var wg sync.WaitGroup
82- wg .Add (1 )
83- go func () {
84- defer wg .Done ()
85- if version , err := tenant .GetDatabaseVersion (ctx , projectRef ); err == nil {
86- linked [utils .Config .Db .Image ] = version
87- }
88- }()
79+ linked := map [string ]string {}
8980 keys , err := tenant .GetApiKeys (ctx , projectRef )
9081 if err != nil {
91- wg .Wait ()
9282 return linked
9383 }
84+ jq := queue .NewJobQueue (5 )
9485 api := tenant .NewTenantAPI (ctx , projectRef , keys .ServiceRole )
95- wg .Add (2 )
96- go func () {
97- defer wg .Done ()
98- if version , err := api .GetGotrueVersion (ctx ); err == nil {
99- linked [utils .Config .Auth .Image ] = version
100- } else if viper .GetBool ("DEBUG" ) {
101- fmt .Fprintln (os .Stderr , err )
102- }
103- }()
104- go func () {
105- defer wg .Done ()
106- if version , err := api .GetPostgrestVersion (ctx ); err == nil {
107- linked [utils .Config .Api .Image ] = version
108- } else if viper .GetBool ("DEBUG" ) {
109- fmt .Fprintln (os .Stderr , err )
86+ jobs := []func () error {
87+ func () error {
88+ version , err := tenant .GetDatabaseVersion (ctx , projectRef )
89+ if err == nil {
90+ linked [utils .Config .Db .Image ] = version
91+ }
92+ return nil
93+ },
94+ func () error {
95+ version , err := api .GetGotrueVersion (ctx )
96+ if err == nil {
97+ linked [utils .Config .Auth .Image ] = version
98+ }
99+ return nil
100+ },
101+ func () error {
102+ version , err := api .GetPostgrestVersion (ctx )
103+ if err == nil {
104+ linked [utils .Config .Api .Image ] = version
105+ }
106+ return nil
107+ },
108+ func () error {
109+ version , err := api .GetStorageVersion (ctx )
110+ if err == nil {
111+ linked [utils .Config .Storage .Image ] = version
112+ }
113+ return err
114+ },
115+ }
116+ // Ignore non-fatal errors linking services
117+ logger := utils .GetDebugLogger ()
118+ for _ , job := range jobs {
119+ if err := jq .Put (job ); err != nil {
120+ fmt .Fprintln (logger , err )
110121 }
111- }()
112- wg .Wait ()
122+ }
123+ if err := jq .Collect (); err != nil {
124+ fmt .Fprintln (logger , err )
125+ }
113126 return linked
114127}
115128
0 commit comments