-
Notifications
You must be signed in to change notification settings - Fork 223
/
delete.go
58 lines (42 loc) · 1016 Bytes
/
delete.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
package redis
import (
"context"
"fmt"
"github.com/spf13/cobra"
"github.com/superfly/flyctl/gql"
"github.com/superfly/flyctl/iostreams"
"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/internal/command"
"github.com/superfly/flyctl/internal/flag"
)
func newDelete() (cmd *cobra.Command) {
const (
long = `Delete an Upstash Redis database`
short = long
usage = "delete <name>"
)
cmd = command.New(usage, short, long, runDelete, command.RequireSession)
flag.Add(cmd)
cmd.Args = cobra.ExactArgs(1)
return cmd
}
func runDelete(ctx context.Context) (err error) {
var (
out = iostreams.FromContext(ctx).Out
client = client.FromContext(ctx).API().GenqClient
)
name := flag.FirstArg(ctx)
_ = `# @genqlient
mutation DeleteAddOn($name: String) {
deleteAddOn(input: {name: $name}) {
deletedAddOnName
}
}
`
_, err = gql.DeleteAddOn(ctx, client, name)
if err != nil {
return
}
fmt.Fprintf(out, "Your Redis database %s was deleted\n", name)
return
}