Skip to content

Commit

Permalink
Merge pull request #926 from tursodatabase/glauber/aws-comms
Browse files Browse the repository at this point in the history
Require users to add a --beta flag for AWS
  • Loading branch information
glommer authored Nov 29, 2024
2 parents 0f6234e + d347790 commit b96a72b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/cmd/beta.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cmd

import (
"github.com/spf13/cobra"
)

var betaFlag bool

func addBetaFlag(cmd *cobra.Command) {
cmd.Flags().BoolVar(&betaFlag, "beta", false, "enable beta features")
}
1 change: 1 addition & 0 deletions internal/cmd/db_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func init() {
addSchemaFlag(createCmd)
addTypeFlag(createCmd)
addSizeLimitFlag(createCmd)
addBetaFlag(createCmd)
}

var createCmd = &cobra.Command{
Expand Down
10 changes: 10 additions & 0 deletions internal/cmd/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"strings"
"time"

"github.com/spf13/cobra"
Expand All @@ -24,6 +25,7 @@ func init() {
addLocationFlag(groupsCreateCmd, "Create the group primary in the specified location")
addWaitFlag(groupsCreateCmd, "Wait for group to be ready")
addCanaryFlag(groupsCreateCmd)
addBetaFlag(groupsCreateCmd)
flags.AddVersion(groupsCreateCmd, "Version of the group. Valid values: 'latest', 'canary' or 'vector'")
groupCmd.AddCommand(groupsDestroyCmd)
addYesFlag(groupsDestroyCmd, "Confirms the destruction of the group, with all its locations and databases.")
Expand Down Expand Up @@ -163,6 +165,14 @@ var groupsDestroyCmd = &cobra.Command{
}

func createGroup(client *turso.Client, name, location, version string) error {
if strings.HasPrefix(location, "aws-") && !betaFlag {
fmt.Printf("AWS regions are currently in %s. Not all features are available in all plans.\nFor a complete list, check %s.\n",
internal.Emph("beta"), internal.Emph("https://docs.turso.tech/cloud-providers"))

fmt.Printf("To create a database on AWS, add the %s flag.\n", internal.Emph("--beta"))
return fmt.Errorf("--beta flag not passed")
}

start := time.Now()
description := fmt.Sprintf("Creating group %s at %s...", internal.Emph(name), internal.Emph(location))
spinner := prompt.Spinner(description)
Expand Down

0 comments on commit b96a72b

Please sign in to comment.