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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/pkg/errors v0.9.1
github.com/planetscale/planetscale-go v0.124.0
github.com/planetscale/planetscale-go v0.125.0
github.com/planetscale/psdb v0.0.0-20240109164348-6848e728f6e7
github.com/planetscale/psdbproxy v0.0.0-20250117221522-0c8e2b0e36e6
github.com/spf13/cobra v1.9.1
Expand All @@ -34,7 +34,7 @@ require (
go.uber.org/zap v1.27.0
go.uber.org/zap/exp v0.3.0
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/oauth2 v0.27.0
golang.org/x/oauth2 v0.28.0
golang.org/x/sync v0.11.0
golang.org/x/sys v0.30.0
golang.org/x/text v0.22.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e h1:MZ8D+Z3m2vvqGZLvoQfpaGg/j1fNDr4j03s3PRz4rVY=
github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e/go.mod h1:hwAsSPQdvPa3WcfKfzTXxtEq/HlqwLjQasfO6QbGo4Q=
github.com/planetscale/planetscale-go v0.124.0 h1:WiPPBEJ0fpg9D9+X+lQC0i7Knb6cQ3yO38Xe90O/qwQ=
github.com/planetscale/planetscale-go v0.124.0/go.mod h1:HXOe9UNFb71w9XIICJj5ncwuY25h2Bng/KrXH80GF0s=
github.com/planetscale/planetscale-go v0.125.0 h1:+R8ZZ0nW+HZhFJGU9IQQxREXM9r7YX6u+S61mFkUWDs=
github.com/planetscale/planetscale-go v0.125.0/go.mod h1:/9cIDXvqglfjCRPzPNP6BklL+J7qq50SKtAP97c4ix0=
github.com/planetscale/psdb v0.0.0-20240109164348-6848e728f6e7 h1:dxdoFKWVDlV1gq8UQC8NWCofLjCEjEHw47gfeojgs28=
github.com/planetscale/psdb v0.0.0-20240109164348-6848e728f6e7/go.mod h1:WZmi4gw3rOK+ryd1inGxgfKwoFV04O7xBCqzWzv0/0U=
github.com/planetscale/psdbproxy v0.0.0-20250117221522-0c8e2b0e36e6 h1:/Ox1ZTAdk+soSngzzKoJh5voOzptrpPrux11o30rIaw=
Expand Down Expand Up @@ -187,8 +187,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/database/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func CreateCmd(ch *cmdutil.Helper) *cobra.Command {
return err
}

createReq.ClusterSize = ps.ClusterSize(clusterSize)
createReq.ClusterSize = clusterSize

createReq.Organization = ch.Config.Organization
createReq.Name = args[0]
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/keyspace/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func CreateCmd(ch *cmdutil.Helper) *cobra.Command {
createReq.Name = keyspace
createReq.Shards = flags.shards
createReq.ExtraReplicas = flags.additionalReplicas
createReq.ClusterSize = planetscale.ClusterSize(flags.clusterSize)
createReq.ClusterSize = flags.clusterSize

client, err := ch.Client()
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/keyspace/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestKeyspace_CreateCmd(t *testing.T) {
ks := &ps.Keyspace{
ID: "wantid",
Name: keyspace,
ClusterSize: ps.ClusterSize("PS-20"),
ClusterSize: "PS-20",
Replicas: 3,
Shards: 2,
}
Expand All @@ -41,7 +41,7 @@ func TestKeyspace_CreateCmd(t *testing.T) {
c.Assert(req.Organization, qt.Equals, org)
c.Assert(req.Branch, qt.Equals, branch)
c.Assert(req.Name, qt.Equals, keyspace)
c.Assert(req.ClusterSize, qt.Equals, ps.ClusterSize("PS-20"))
c.Assert(req.ClusterSize, qt.Equals, "PS-20")
c.Assert(req.ExtraReplicas, qt.Equals, 1)
c.Assert(req.Shards, qt.Equals, 2)

Expand Down Expand Up @@ -86,7 +86,7 @@ func TestKeyspace_CreateCmdOnlyClusterSize(t *testing.T) {
ks := &ps.Keyspace{
ID: "wantid",
Name: keyspace,
ClusterSize: ps.ClusterSize("PS-10"),
ClusterSize: "PS-10",
Replicas: 2,
ExtraReplicas: 0,
Shards: 1,
Expand All @@ -98,7 +98,7 @@ func TestKeyspace_CreateCmdOnlyClusterSize(t *testing.T) {
c.Assert(req.Organization, qt.Equals, org)
c.Assert(req.Branch, qt.Equals, branch)
c.Assert(req.Name, qt.Equals, keyspace)
c.Assert(req.ClusterSize, qt.Equals, ps.ClusterSize("PS-10"))
c.Assert(req.ClusterSize, qt.Equals, "PS-10")
c.Assert(req.ExtraReplicas, qt.Equals, 0)
c.Assert(req.Shards, qt.Equals, 1)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/keyspace/resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func ResizeCmd(ch *cmdutil.Helper) *cobra.Command {
}

if cmd.Flags().Changed("cluster-size") {
size := ps.ClusterSize(flags.clusterSize)
size := flags.clusterSize
resizeReq.ClusterSize = &size
}

Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/keyspace/resize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestKeyspace_ResizeCmd(t *testing.T) {
c.Assert(req.Branch, qt.Equals, branch)
c.Assert(req.Keyspace, qt.Equals, keyspace)
c.Assert(*req.ExtraReplicas, qt.Equals, uint(3))
c.Assert(*req.ClusterSize, qt.Equals, ps.ClusterSize("PS_10"))
c.Assert(*req.ClusterSize, qt.Equals, "PS_10")

return krr, nil
},
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestKeyspace_ResizeCmdOnlyClusterSize(t *testing.T) {
c.Assert(req.Branch, qt.Equals, branch)
c.Assert(req.Keyspace, qt.Equals, keyspace)
c.Assert(req.ExtraReplicas, qt.IsNil)
c.Assert(*req.ClusterSize, qt.Equals, ps.ClusterSize("PS_10"))
c.Assert(*req.ClusterSize, qt.Equals, "PS_10")

return krr, nil
},
Expand Down
14 changes: 11 additions & 3 deletions internal/cmd/size/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func ClusterCmd(ch *cmdutil.Helper) *cobra.Command {
func ListCmd(ch *cmdutil.Helper) *cobra.Command {
var flags struct {
region string
metal bool
}

cmd := &cobra.Command{
Expand All @@ -47,11 +48,12 @@ func ListCmd(ch *cmdutil.Helper) *cobra.Command {
return err
}

return ch.Printer.PrintResource(toClusterSKUs(clusterSKUs))
return ch.Printer.PrintResource(toClusterSKUs(clusterSKUs, flags.metal))
},
}

cmd.Flags().StringVar(&flags.region, "region", "", "view cluster sizes and rates for a specific region")
cmd.Flags().BoolVar(&flags.metal, "metal", false, "view cluster sizes and rates for clusters with metal storage")

cmd.RegisterFlagCompletionFunc("region", func(cmd *cobra.Command, args []string, toComplete string) ([]cobra.Completion, cobra.ShellCompDirective) {
return cmdutil.RegionsCompletionFunc(ch, cmd, args, toComplete)
Expand Down Expand Up @@ -103,12 +105,18 @@ func toClusterSKU(clusterSKU *planetscale.ClusterSKU) *ClusterSKU {
return cluster
}

func toClusterSKUs(clusterSKUs []*planetscale.ClusterSKU) []*ClusterSKU {
func toClusterSKUs(clusterSKUs []*planetscale.ClusterSKU, onlyMetal bool) []*ClusterSKU {
clusters := make([]*ClusterSKU, 0, len(clusterSKUs))

for _, clusterSKU := range clusterSKUs {
if clusterSKU.Enabled && clusterSKU.Rate != nil && clusterSKU.Name != "PS_DEV" {
clusters = append(clusters, toClusterSKU(clusterSKU))
if onlyMetal {
if clusterSKU.Metal {
clusters = append(clusters, toClusterSKU(clusterSKU))
}
} else {
clusters = append(clusters, toClusterSKU(clusterSKU))
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/cmdutil/cmdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ func DeployRequestBranchToNumber(ctx context.Context, client *ps.Client, organiz
return deployRequests[0].Number, nil
}

func ToClusterSizeSlug(c ps.ClusterSize) string {
return strings.ReplaceAll(string(c), "_", "-")
func ToClusterSizeSlug(c string) string {
return strings.ReplaceAll(c, "_", "-")
}

func SnakeToSentenceCase(s string) string {
Expand Down