Skip to content

Commit 35e067f

Browse files
authored
Filter deprecated regions in remaining flyctl commands (#4616)
1 parent 9afca05 commit 35e067f

File tree

9 files changed

+37
-3
lines changed

9 files changed

+37
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ require (
7474
github.com/spf13/pflag v1.0.9
7575
github.com/spf13/viper v1.20.1
7676
github.com/stretchr/testify v1.11.1
77-
github.com/superfly/fly-go v0.1.63
77+
github.com/superfly/fly-go v0.1.64
7878
github.com/superfly/graphql v0.2.6
7979
github.com/superfly/lfsc-go v0.1.1
8080
github.com/superfly/macaroon v0.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,8 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
635635
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
636636
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
637637
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
638-
github.com/superfly/fly-go v0.1.63 h1:u5QlVBXkQgBMfA+KiRFvZzTnOAYi6YTabXalj5EOvrk=
639-
github.com/superfly/fly-go v0.1.63/go.mod h1:wpq4XNor10w9KurA15CBYRnhtT2mnemAXYHuqkhp2vI=
638+
github.com/superfly/fly-go v0.1.64 h1:kKpr1qcNn0ZM3IvMz7AthDrSt/4Haor7c7AE/t6lEqw=
639+
github.com/superfly/fly-go v0.1.64/go.mod h1:wpq4XNor10w9KurA15CBYRnhtT2mnemAXYHuqkhp2vI=
640640
github.com/superfly/graphql v0.2.6 h1:zppbodNerWecoXEdjkhrqaNaSjGqobhXNlViHFuZzb4=
641641
github.com/superfly/graphql v0.2.6/go.mod h1:CVfDl31srm8HnJ9udwLu6hFNUW/P6GUM2dKcG1YQ8jc=
642642
github.com/superfly/lfsc-go v0.1.1 h1:dGjLgt81D09cG+aR9lJZIdmonjZSR5zYCi7s54+ZU2Q=

gql/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8892,6 +8892,7 @@ type Region {
88928892
"""
88938893
code: String!
88948894
gatewayAvailable: Boolean!
8895+
deprecated: Boolean!
88958896

88968897
"""
88978898
The latitude of this region

internal/command/curl/curl.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"time"
1717

1818
"github.com/dustin/go-humanize"
19+
"github.com/samber/lo"
1920
"github.com/spf13/cobra"
2021

2122
fly "github.com/superfly/fly-go"
@@ -90,6 +91,11 @@ func fetchRegionCodes(ctx context.Context) (codes []string, err error) {
9091
return
9192
}
9293

94+
// Filter out deprecated regions
95+
regions = lo.Filter(regions, func(r fly.Region, _ int) bool {
96+
return !r.Deprecated
97+
})
98+
9399
for _, region := range regions {
94100
codes = append(codes, region.Code)
95101
}

internal/command/launch/launch_databases.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ func (state *launchState) createUpstashRedis(ctx context.Context) error {
389389
if err != nil {
390390
return err
391391
}
392+
// Filter out deprecated regions
393+
regions = lo.Filter(regions, func(r fly.Region, _ int) bool {
394+
return !r.Deprecated
395+
})
392396
for _, code := range redisPlan.ReadReplicas {
393397
if region, ok := lo.Find(regions, func(r fly.Region) bool { return r.Code == code }); ok {
394398
readReplicaRegions = append(readReplicaRegions, region)

internal/command/launch/plan_builder.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212
"unicode"
1313

14+
"github.com/samber/lo"
1415
fly "github.com/superfly/fly-go"
1516
"github.com/superfly/flyctl/helpers"
1617
"github.com/superfly/flyctl/internal/appconfig"
@@ -725,6 +726,11 @@ func getRegionByCode(ctx context.Context, regionCode string) (*fly.Region, error
725726
return nil, err
726727
}
727728

729+
// Filter out deprecated regions
730+
allRegions = lo.Filter(allRegions, func(r fly.Region, _ int) bool {
731+
return !r.Deprecated
732+
})
733+
728734
for _, r := range allRegions {
729735
if r.Code == regionCode {
730736
return &r, nil

internal/command/launch/state.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ func (state *launchState) Region(ctx context.Context) (fly.Region, error) {
7979
if err != nil {
8080
return nil, err
8181
}
82+
// Filter out deprecated regions
83+
regions = lo.Filter(regions, func(r fly.Region, _ int) bool {
84+
return !r.Deprecated
85+
})
8286
return regions, nil
8387
})
8488
if err != nil {

internal/command/lfsc/regions.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import (
55
"fmt"
66
"sort"
77

8+
"github.com/samber/lo"
89
"github.com/spf13/cobra"
10+
fly "github.com/superfly/fly-go"
911
"github.com/superfly/flyctl/internal/command"
1012
"github.com/superfly/flyctl/internal/config"
1113
"github.com/superfly/flyctl/internal/flag"
@@ -40,6 +42,11 @@ func runRegions(ctx context.Context) error {
4042
return fmt.Errorf("failed retrieving regions: %w", err)
4143
}
4244

45+
// Filter out deprecated regions
46+
flyRegions = lo.Filter(flyRegions, func(r fly.Region, _ int) bool {
47+
return !r.Deprecated
48+
})
49+
4350
lfscClient := lfsc.NewClient()
4451
lfscClient.URL = flag.GetString(ctx, "url")
4552

internal/flag/completion/completions.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ func CompleteRegions(
104104
if err != nil {
105105
return nil, err
106106
}
107+
108+
// Filter out deprecated regions
109+
regions = lo.Filter(regions, func(r fly.Region, _ int) bool {
110+
return !r.Deprecated
111+
})
112+
107113
regionNames := lo.FilterMap(regions, func(region fly.Region, _ int) (string, bool) {
108114
if strings.HasPrefix(region.Code, partial) {
109115
return format(region), true

0 commit comments

Comments
 (0)