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
7 changes: 2 additions & 5 deletions cmd/branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ var (
Short: "Manage Supabase preview branches",
}

branchRegion = utils.EnumFlag{
Allowed: awsRegions(),
}
persistent bool
withData bool
notifyURL string
Expand All @@ -49,7 +46,7 @@ var (
}
cmdFlags := cmd.Flags()
if cmdFlags.Changed("region") {
body.Region = &branchRegion.Value
body.Region = &region.Value
}
if cmdFlags.Changed("size") {
body.DesiredInstanceSize = (*api.CreateBranchBodyDesiredInstanceSize)(&size.Value)
Expand Down Expand Up @@ -206,7 +203,7 @@ func init() {
branchFlags := branchesCmd.PersistentFlags()
branchFlags.StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.")
createFlags := branchCreateCmd.Flags()
createFlags.Var(&branchRegion, "region", "Select a region to deploy the branch database.")
createFlags.Var(&region, "region", "Select a region to deploy the branch database.")
createFlags.Var(&size, "size", "Select a desired instance size for the branch database.")
createFlags.BoolVar(&persistent, "persistent", false, "Whether to create a persistent branch.")
createFlags.BoolVar(&withData, "with-data", false, "Whether to clone production data to the branch database.")
Expand Down
12 changes: 1 addition & 11 deletions cmd/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"os"
"sort"

"github.com/spf13/afero"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -30,7 +29,7 @@ var (
orgId string
dbPassword string
region = utils.EnumFlag{
Allowed: awsRegions(),
Allowed: utils.AwsRegions(),
}
size = utils.EnumFlag{
Allowed: []string{
Expand Down Expand Up @@ -153,12 +152,3 @@ func init() {
projectsCmd.AddCommand(projectsApiKeysCmd)
rootCmd.AddCommand(projectsCmd)
}

func awsRegions() []string {
result := make([]string, len(utils.CurrentProfile.ProjectRegions))
for i, region := range utils.CurrentProfile.ProjectRegions {
result[i] = string(region)
}
sort.Strings(result)
return result
}
10 changes: 10 additions & 0 deletions internal/utils/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utils
import (
"context"
"fmt"
"sort"
"strings"

"github.com/go-errors/errors"
Expand Down Expand Up @@ -128,3 +129,12 @@ func getProfileName(fsys afero.Fs) string {
return prof
}
}

func AwsRegions() []string {
result := make([]string, len(allProfiles[0].ProjectRegions))
for i, region := range allProfiles[0].ProjectRegions {
result[i] = string(region)
}
sort.Strings(result)
return result
}
Loading