-
Notifications
You must be signed in to change notification settings - Fork 223
/
redis.go
63 lines (50 loc) · 1.11 KB
/
redis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package redis
import (
"context"
"github.com/spf13/cobra"
"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/gql"
"github.com/superfly/flyctl/internal/command"
)
// TODO: make internal once the open command has been deprecated
func New() (cmd *cobra.Command) {
const (
long = `Launch and manage Redis databases managed by Upstash.com`
short = long
)
cmd = command.New("redis", short, long, nil)
cmd.AddCommand(
newCreate(),
newList(),
newDestroy(),
newStatus(),
newPlans(),
newUpdate(),
newConnect(),
newDashboard(),
newReset(),
)
return cmd
}
func GetExcludedRegions(ctx context.Context) (excludedRegions []string, err error) {
client := client.FromContext(ctx).API().GenqClient
_ = `# @genqlient
query GetAddOnProvider($name: String!) {
addOnProvider(name: $name) {
id
name
excludedRegions {
code
}
}
}
`
response, err := gql.GetAddOnProvider(ctx, client, "upstash_redis")
if err != nil {
return nil, err
}
for _, region := range response.AddOnProvider.ExcludedRegions {
excludedRegions = append(excludedRegions, region.Code)
}
return
}