Skip to content

Commit 64465dd

Browse files
authored
fix: validate pooler domain per profile (#4358)
1 parent e1c3bfc commit 64465dd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

internal/utils/connect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func assertDomainInProfile(host string) error {
9898
if err != nil {
9999
return errors.Errorf("failed to parse pooler TLD: %w", err)
100100
}
101-
if !strings.HasSuffix(CurrentProfile.APIURL, "."+domain) {
101+
if len(CurrentProfile.PoolerHost) > 0 && !strings.EqualFold(CurrentProfile.PoolerHost, domain) {
102102
return errors.Errorf("Pooler domain does not belong to current profile: %s", domain)
103103
}
104104
return nil

internal/utils/profile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Profile struct {
1616
APIURL string `mapstructure:"api_url" validate:"required,http_url"`
1717
DashboardURL string `mapstructure:"dashboard_url" validate:"required,http_url"`
1818
ProjectHost string `mapstructure:"project_host" validate:"required,hostname_rfc1123"`
19+
PoolerHost string `mapstructure:"pooler_host" validate:"omitempty,hostname_rfc1123"`
1920
DocsURL string `mapstructure:"docs_url" validate:"omitempty,http_url"`
2021
StudioImage string `mapstructure:"studio_image"`
2122
}
@@ -26,12 +27,14 @@ var allProfiles = []Profile{{
2627
DashboardURL: "https://supabase.com/dashboard",
2728
DocsURL: "https://supabase.com/docs",
2829
ProjectHost: "supabase.co",
30+
PoolerHost: "supabase.com",
2931
}, {
3032
Name: "supabase-staging",
3133
APIURL: "https://api.supabase.green",
3234
DashboardURL: "https://supabase.green/dashboard",
3335
DocsURL: "https://supabase.com/docs",
3436
ProjectHost: "supabase.red",
37+
PoolerHost: "supabase.green",
3538
}, {
3639
Name: "supabase-local",
3740
APIURL: "http://localhost:8080",
@@ -44,6 +47,7 @@ var allProfiles = []Profile{{
4447
DashboardURL: "https://cloud.snap.com/dashboard",
4548
DocsURL: "https://cloud.snap.com/docs",
4649
ProjectHost: "snapcloud.dev",
50+
PoolerHost: "snapcloud.co",
4751
}}
4852

4953
var CurrentProfile Profile

0 commit comments

Comments
 (0)