Skip to content

Commit e35c33f

Browse files
authored
fix: use service key for version checks (#3961)
1 parent bea370c commit e35c33f

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

internal/link/link.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(
3939
if err != nil {
4040
return err
4141
}
42-
LinkServices(ctx, projectRef, keys.Anon, fsys)
42+
LinkServices(ctx, projectRef, keys.ServiceRole, fsys)
4343

4444
// 2. Check database connection
4545
config := flags.NewDbConfigWithPassword(ctx, projectRef)
@@ -66,7 +66,7 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(
6666
return nil
6767
}
6868

69-
func LinkServices(ctx context.Context, projectRef, anonKey string, fsys afero.Fs) {
69+
func LinkServices(ctx context.Context, projectRef, serviceKey string, fsys afero.Fs) {
7070
// Ignore non-fatal errors linking services
7171
var wg sync.WaitGroup
7272
wg.Add(8)
@@ -106,7 +106,7 @@ func LinkServices(ctx context.Context, projectRef, anonKey string, fsys afero.Fs
106106
fmt.Fprintln(os.Stderr, err)
107107
}
108108
}()
109-
api := tenant.NewTenantAPI(ctx, projectRef, anonKey)
109+
api := tenant.NewTenantAPI(ctx, projectRef, serviceKey)
110110
go func() {
111111
defer wg.Done()
112112
if err := linkPostgrestVersion(ctx, api, fsys); err != nil && viper.GetBool("DEBUG") {

internal/services/services.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"sync"
1010

1111
"github.com/spf13/afero"
12+
"github.com/spf13/viper"
1213
"github.com/supabase/cli/internal/migration/list"
1314
"github.com/supabase/cli/internal/utils"
1415
"github.com/supabase/cli/internal/utils/flags"
@@ -79,18 +80,22 @@ func listRemoteImages(ctx context.Context, projectRef string) map[string]string
7980
wg.Wait()
8081
return linked
8182
}
82-
api := tenant.NewTenantAPI(ctx, projectRef, keys.Anon)
83+
api := tenant.NewTenantAPI(ctx, projectRef, keys.ServiceRole)
8384
wg.Add(2)
8485
go func() {
8586
defer wg.Done()
8687
if version, err := api.GetGotrueVersion(ctx); err == nil {
8788
linked[utils.Config.Auth.Image] = version
89+
} else if viper.GetBool("DEBUG") {
90+
fmt.Fprintln(os.Stderr, err)
8891
}
8992
}()
9093
go func() {
9194
defer wg.Done()
9295
if version, err := api.GetPostgrestVersion(ctx); err == nil {
9396
linked[utils.Config.Api.Image] = version
97+
} else if viper.GetBool("DEBUG") {
98+
fmt.Fprintln(os.Stderr, err)
9499
}
95100
}()
96101
wg.Wait()

internal/utils/tenant/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ type TenantAPI struct {
8888
*fetcher.Fetcher
8989
}
9090

91-
func NewTenantAPI(ctx context.Context, projectRef, anonKey string) TenantAPI {
91+
func NewTenantAPI(ctx context.Context, projectRef, serviceKey string) TenantAPI {
9292
return TenantAPI{Fetcher: fetcher.NewServiceGateway(
9393
"https://"+utils.GetSupabaseHost(projectRef),
94-
anonKey,
94+
serviceKey,
9595
fetcher.WithUserAgent("SupabaseCLI/"+utils.Version),
9696
)}
9797
}

0 commit comments

Comments
 (0)