Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions cmd/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,9 @@ func init() {
}

func awsRegions() []string {
result := make([]string, len(utils.RegionMap))
i := 0
for k := range utils.RegionMap {
result[i] = k
i++
result := make([]string, len(utils.CurrentProfile.ProjectRegions))
for i, region := range utils.CurrentProfile.ProjectRegions {
result[i] = string(region)
}
sort.Strings(result)
return result
Expand Down
11 changes: 6 additions & 5 deletions internal/projects/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,12 @@ func promptOrgId(ctx context.Context) (string, error) {

func promptProjectRegion(ctx context.Context) (api.V1CreateProjectBodyRegion, error) {
title := "Which region do you want to host the project in?"
items := make([]utils.PromptItem, len(utils.RegionMap))
i := 0
for k, v := range utils.RegionMap {
items[i] = utils.PromptItem{Summary: k, Details: v}
i++
items := make([]utils.PromptItem, len(utils.CurrentProfile.ProjectRegions))
for i, region := range utils.CurrentProfile.ProjectRegions {
items[i] = utils.PromptItem{
Summary: string(region),
Details: utils.FormatRegion(string(region)),
}
}
choice, err := utils.PromptChoice(ctx, title, items)
if err != nil {
Expand Down
17 changes: 0 additions & 17 deletions internal/utils/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,6 @@ func GetSupabase() *supabase.ClientWithResponses {
// Used by unit tests
var DefaultApiHost = CurrentProfile.APIURL

var RegionMap = map[string]string{
"ap-northeast-1": "Northeast Asia (Tokyo)",
"ap-northeast-2": "Northeast Asia (Seoul)",
"ap-south-1": "South Asia (Mumbai)",
"ap-southeast-1": "Southeast Asia (Singapore)",
"ap-southeast-2": "Oceania (Sydney)",
"ca-central-1": "Canada (Central)",
"eu-central-1": "Central EU (Frankfurt)",
"eu-west-1": "West EU (Ireland)",
"eu-west-2": "West EU (London)",
"eu-west-3": "West EU (Paris)",
"sa-east-1": "South America (São Paulo)",
"us-east-1": "East US (North Virginia)",
"us-west-1": "West US (North California)",
"us-west-2": "West US (Oregon)",
}

func GetSupabaseAPIHost() string {
return CurrentProfile.APIURL
}
Expand Down
51 changes: 43 additions & 8 deletions internal/utils/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ import (
"github.com/go-playground/validator/v10"
"github.com/spf13/afero"
"github.com/spf13/viper"
"github.com/supabase/cli/pkg/api"
)

type Profile struct {
Name string `mapstructure:"name" validate:"required"`
APIURL string `mapstructure:"api_url" validate:"required,http_url"`
DashboardURL string `mapstructure:"dashboard_url" validate:"required,http_url"`
DocsURL string `mapstructure:"docs_url" validate:"omitempty,http_url"`
ProjectHost string `mapstructure:"project_host" validate:"required,hostname_rfc1123"`
PoolerHost string `mapstructure:"pooler_host" validate:"omitempty,hostname_rfc1123"`
AuthClientID string `mapstructure:"client_id" validate:"omitempty,uuid4"`
StudioImage string `mapstructure:"studio_image"`
Name string `mapstructure:"name" validate:"required"`
APIURL string `mapstructure:"api_url" validate:"required,http_url"`
DashboardURL string `mapstructure:"dashboard_url" validate:"required,http_url"`
DocsURL string `mapstructure:"docs_url" validate:"omitempty,http_url"`
ProjectHost string `mapstructure:"project_host" validate:"required,hostname_rfc1123"`
PoolerHost string `mapstructure:"pooler_host" validate:"omitempty,hostname_rfc1123"`
AuthClientID string `mapstructure:"client_id" validate:"omitempty,uuid4"`
StudioImage string `mapstructure:"studio_image"`
ProjectRegions []api.V1CreateProjectBodyRegion `mapstructure:"regions"`
}

var allProfiles = []Profile{{
Expand All @@ -29,19 +31,49 @@ var allProfiles = []Profile{{
DocsURL: "https://supabase.com/docs",
ProjectHost: "supabase.co",
PoolerHost: "supabase.com",
ProjectRegions: []api.V1CreateProjectBodyRegion{
api.V1CreateProjectBodyRegionApEast1,
api.V1CreateProjectBodyRegionApNortheast1,
api.V1CreateProjectBodyRegionApNortheast2,
api.V1CreateProjectBodyRegionApSouth1,
api.V1CreateProjectBodyRegionApSoutheast1,
api.V1CreateProjectBodyRegionApSoutheast2,
api.V1CreateProjectBodyRegionCaCentral1,
api.V1CreateProjectBodyRegionEuCentral1,
api.V1CreateProjectBodyRegionEuCentral2,
api.V1CreateProjectBodyRegionEuNorth1,
api.V1CreateProjectBodyRegionEuWest1,
api.V1CreateProjectBodyRegionEuWest2,
api.V1CreateProjectBodyRegionEuWest3,
api.V1CreateProjectBodyRegionSaEast1,
api.V1CreateProjectBodyRegionUsEast1,
api.V1CreateProjectBodyRegionUsEast2,
api.V1CreateProjectBodyRegionUsWest1,
api.V1CreateProjectBodyRegionUsWest2,
},
}, {
Name: "supabase-staging",
APIURL: "https://api.supabase.green",
DashboardURL: "https://supabase.green/dashboard",
DocsURL: "https://supabase.com/docs",
ProjectHost: "supabase.red",
PoolerHost: "supabase.green",
ProjectRegions: []api.V1CreateProjectBodyRegion{
api.V1CreateProjectBodyRegionApSoutheast1,
api.V1CreateProjectBodyRegionUsEast1,
api.V1CreateProjectBodyRegionEuCentral1,
},
}, {
Name: "supabase-local",
APIURL: "http://localhost:8080",
DashboardURL: "http://localhost:8082",
DocsURL: "https://supabase.com/docs",
ProjectHost: "supabase.red",
ProjectRegions: []api.V1CreateProjectBodyRegion{
api.V1CreateProjectBodyRegionApSoutheast1,
api.V1CreateProjectBodyRegionUsEast1,
api.V1CreateProjectBodyRegionEuCentral1,
},
}, {
Name: "snap",
APIURL: "https://cloudapi.snap.com",
Expand All @@ -50,6 +82,9 @@ var allProfiles = []Profile{{
ProjectHost: "snapcloud.dev",
PoolerHost: "snapcloud.co",
AuthClientID: "f7573b20-df47-48f1-b606-e8db4ec16252",
ProjectRegions: []api.V1CreateProjectBodyRegion{
api.V1CreateProjectBodyRegionUsEast1,
},
}}

var CurrentProfile Profile
Expand Down
23 changes: 22 additions & 1 deletion internal/utils/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,29 @@ func parse(layout, value string) string {
return FormatTime(t)
}

var regionMap = map[string]string{
"ap-east-1": "East Asia (Hong Kong)",
"ap-northeast-1": "Northeast Asia (Tokyo)",
"ap-northeast-2": "Northeast Asia (Seoul)",
"ap-south-1": "South Asia (Mumbai)",
"ap-southeast-1": "Southeast Asia (Singapore)",
"ap-southeast-2": "Oceania (Sydney)",
"ca-central-1": "Canada (Central)",
"eu-central-1": "Central EU (Frankfurt)",
"eu-central-2": "Central Europe (Zurich)",
"eu-north-1": "North EU (Stockholm)",
"eu-west-1": "West EU (Ireland)",
"eu-west-2": "West Europe (London)",
"eu-west-3": "West EU (Paris)",
"sa-east-1": "South America (São Paulo)",
"us-east-1": "East US (North Virginia)",
"us-east-2": "East US (Ohio)",
"us-west-1": "West US (North California)",
"us-west-2": "West US (Oregon)",
}

func FormatRegion(region string) string {
if readable, ok := RegionMap[region]; ok {
if readable, ok := regionMap[region]; ok {
return readable
}
return region
Expand Down