Skip to content

Commit 0c5cf93

Browse files
author
Joshua Sierles
authored
Add more MySQL commands (#3806)
* Add more mysql commands * lint
1 parent e7d4a06 commit 0c5cf93

File tree

10 files changed

+199
-7
lines changed

10 files changed

+199
-7
lines changed

gql/generated.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gql/schema.graphql

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ enum AddOnType {
357357
"""
358358
enveloop
359359

360+
"""
361+
A MySQL database
362+
"""
363+
fly_mysql
364+
360365
"""
361366
A Kubernetes cluster
362367
"""
@@ -3282,6 +3287,7 @@ input CreateOrganizationInput {
32823287
Whether or not new apps in this org use Apps V2 by default
32833288
"""
32843289
appsV2DefaultOn: Boolean
3290+
billingParentOrganizationId: ID
32853291

32863292
"""
32873293
A unique identifier for the client performing the mutation.
@@ -5071,6 +5077,44 @@ type EnablePostgresConsulPayload {
50715077
consulUrl: String!
50725078
}
50735079

5080+
"""
5081+
Autogenerated input type of EnsureDepotRemoteBuilder
5082+
"""
5083+
input EnsureDepotRemoteBuilderInput {
5084+
"""
5085+
The unique application name
5086+
"""
5087+
appName: String
5088+
5089+
"""
5090+
A unique identifier for the client performing the mutation.
5091+
"""
5092+
clientMutationId: String
5093+
5094+
"""
5095+
The node ID of the organization
5096+
"""
5097+
organizationId: ID
5098+
5099+
"""
5100+
Desired region for the remote builder
5101+
"""
5102+
region: String
5103+
}
5104+
5105+
"""
5106+
Autogenerated return type of EnsureDepotRemoteBuilder.
5107+
"""
5108+
type EnsureDepotRemoteBuilderPayload {
5109+
buildId: String!
5110+
buildToken: String!
5111+
5112+
"""
5113+
A unique identifier for the client performing the mutation.
5114+
"""
5115+
clientMutationId: String
5116+
}
5117+
50745118
"""
50755119
Autogenerated input type of EnsureFlyctlMachineHost
50765120
"""
@@ -7000,6 +7044,12 @@ type Mutations {
70007044
"""
70017045
input: EnablePostgresConsulInput!
70027046
): EnablePostgresConsulPayload
7047+
ensureDepotRemoteBuilder(
7048+
"""
7049+
Parameters for EnsureDepotRemoteBuilder
7050+
"""
7051+
input: EnsureDepotRemoteBuilderInput!
7052+
): EnsureDepotRemoteBuilderPayload
70037053
ensureFlyctlMachineHost(
70047054
"""
70057055
Parameters for EnsureFlyctlMachineHost
@@ -8555,6 +8605,11 @@ type Queries {
85558605
Find a domain by name
85568606
"""
85578607
domain(name: String!): Domain
8608+
8609+
"""
8610+
internal field for inter-service authz check
8611+
"""
8612+
flapsAuthzCheck: Boolean!
85588613
githubIntegration: GithubIntegration! @deprecated(reason: "deprecated")
85598614
herokuIntegration: HerokuIntegration!
85608615

@@ -8973,6 +9028,7 @@ type Release implements Node {
89739028
"""
89749029
imageRef: String
89759030
inProgress: Boolean! @deprecated(reason: "use deployment.inProgress")
9031+
metadata: JSON
89769032

89779033
"""
89789034
The reason for the release
@@ -10850,6 +10906,11 @@ input UpdateReleaseInput {
1085010906
"""
1085110907
clientMutationId: String
1085210908

10909+
"""
10910+
The metadata for the release
10911+
"""
10912+
metadata: JSON
10913+
1085310914
"""
1085410915
The ID of the release
1085510916
"""
@@ -10858,7 +10919,7 @@ input UpdateReleaseInput {
1085810919
"""
1085910920
The new status for the release
1086010921
"""
10861-
status: String!
10922+
status: String
1086210923
}
1086310924

1086410925
"""

internal/command/extensions/extensions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77
"github.com/superfly/flyctl/internal/command"
88
"github.com/superfly/flyctl/internal/command/extensions/arcjet"
99
"github.com/superfly/flyctl/internal/command/extensions/enveloop"
10+
"github.com/superfly/flyctl/internal/command/extensions/fly_mysql"
1011
"github.com/superfly/flyctl/internal/command/extensions/kafka"
1112
"github.com/superfly/flyctl/internal/command/extensions/kubernetes"
12-
"github.com/superfly/flyctl/internal/command/extensions/mysql"
1313
sentry_ext "github.com/superfly/flyctl/internal/command/extensions/sentry"
1414
"github.com/superfly/flyctl/internal/command/extensions/supabase"
1515
"github.com/superfly/flyctl/internal/command/extensions/tigris"
@@ -36,7 +36,7 @@ func New() (cmd *cobra.Command) {
3636
vector.New(),
3737
enveloop.New(),
3838
arcjet.New(),
39-
mysql.New(),
39+
fly_mysql.New(),
4040
wafris.New(),
4141
)
4242
return

internal/command/extensions/mysql/create.go renamed to internal/command/extensions/fly_mysql/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package mysql
1+
package fly_mysql
22

33
import (
44
"context"
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package fly_mysql
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/spf13/cobra"
8+
9+
"github.com/superfly/flyctl/gql"
10+
"github.com/superfly/flyctl/iostreams"
11+
12+
"github.com/superfly/flyctl/internal/command"
13+
extensions_core "github.com/superfly/flyctl/internal/command/extensions/core"
14+
"github.com/superfly/flyctl/internal/flag"
15+
"github.com/superfly/flyctl/internal/flyutil"
16+
"github.com/superfly/flyctl/internal/prompt"
17+
)
18+
19+
func destroy() (cmd *cobra.Command) {
20+
const (
21+
long = `Permanently destroy a MySQL database`
22+
23+
short = long
24+
usage = "destroy [name]"
25+
)
26+
27+
cmd = command.New(usage, short, long, runDestroy, command.RequireSession, command.LoadAppNameIfPresent)
28+
29+
cmd.Args = cobra.MaximumNArgs(1)
30+
31+
flag.Add(cmd,
32+
flag.App(),
33+
flag.AppConfig(),
34+
extensions_core.SharedFlags,
35+
)
36+
37+
return cmd
38+
}
39+
40+
func runDestroy(ctx context.Context) (err error) {
41+
io := iostreams.FromContext(ctx)
42+
colorize := io.ColorScheme()
43+
44+
extension, _, err := extensions_core.Discover(ctx, gql.AddOnTypeFlyMysql)
45+
if err != nil {
46+
return err
47+
}
48+
49+
if !flag.GetYes(ctx) {
50+
const msg = "Destroying a MySQL database is not reversible."
51+
fmt.Fprintln(io.ErrOut, colorize.Red(msg))
52+
53+
switch confirmed, err := prompt.Confirmf(ctx, "Destroy MySQL database %s?", extension.Name); {
54+
case err == nil:
55+
if !confirmed {
56+
return nil
57+
}
58+
case prompt.IsNonInteractive(err):
59+
return prompt.NonInteractiveError("yes flag must be specified when not running interactively")
60+
default:
61+
return err
62+
}
63+
}
64+
65+
var (
66+
out = iostreams.FromContext(ctx).Out
67+
client = flyutil.ClientFromContext(ctx).GenqClient()
68+
)
69+
70+
_, err = gql.DeleteAddOn(ctx, client, extension.Name)
71+
72+
if err != nil {
73+
return
74+
}
75+
76+
fmt.Fprintf(out, "Your MySQL database %s was destroyed\n", extension.Name)
77+
78+
return
79+
}

internal/command/extensions/mysql/mysql.go renamed to internal/command/extensions/fly_mysql/fly_mysql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package mysql
1+
package fly_mysql
22

33
import (
44
"github.com/spf13/cobra"
@@ -13,7 +13,7 @@ func New() (cmd *cobra.Command) {
1313
)
1414

1515
cmd = command.New("mysql", short, long, nil)
16-
cmd.AddCommand(create(), list())
16+
cmd.AddCommand(create(), list(), status(), destroy())
1717

1818
return cmd
1919
}

internal/command/extensions/mysql/list.go renamed to internal/command/extensions/fly_mysql/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package mysql
1+
package fly_mysql
22

33
import (
44
"context"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package fly_mysql
2+
3+
import (
4+
"context"
5+
6+
"github.com/spf13/cobra"
7+
"github.com/superfly/flyctl/gql"
8+
"github.com/superfly/flyctl/internal/command"
9+
extensions_core "github.com/superfly/flyctl/internal/command/extensions/core"
10+
"github.com/superfly/flyctl/internal/flag"
11+
)
12+
13+
func status() *cobra.Command {
14+
const (
15+
short = "Show details about a MySQL database"
16+
long = short + "\n"
17+
18+
usage = "status [name]"
19+
)
20+
21+
cmd := command.New(usage, short, long, runStatus,
22+
command.RequireSession, command.LoadAppNameIfPresent,
23+
)
24+
25+
cmd.Args = cobra.MaximumNArgs(1)
26+
27+
flag.Add(cmd,
28+
flag.App(),
29+
flag.AppConfig(),
30+
extensions_core.SharedFlags,
31+
)
32+
33+
return cmd
34+
}
35+
36+
func runStatus(ctx context.Context) (err error) {
37+
return extensions_core.Status(ctx, gql.AddOnTypeFlyMysql)
38+
}

internal/command/mysql/mysql.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package mysql
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
"github.com/superfly/flyctl/internal/command/extensions/fly_mysql"
6+
)
7+
8+
func New() (cmd *cobra.Command) {
9+
return fly_mysql.New()
10+
}

internal/command/root/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/superfly/flyctl/internal/command/machine"
4242
"github.com/superfly/flyctl/internal/command/metrics"
4343
"github.com/superfly/flyctl/internal/command/move"
44+
"github.com/superfly/flyctl/internal/command/mysql"
4445
"github.com/superfly/flyctl/internal/command/open"
4546
"github.com/superfly/flyctl/internal/command/orgs"
4647
"github.com/superfly/flyctl/internal/command/ping"
@@ -109,6 +110,7 @@ func New() *cobra.Command {
109110
agent.New(),
110111
group(image.New(), "configuring"),
111112
group(incidents.New(), "upkeep"),
113+
group(mysql.New(), "dbs_and_extensions"),
112114
group(ping.New(), "upkeep"),
113115
group(proxy.New(), "upkeep"),
114116
group(postgres.New(), "dbs_and_extensions"),

0 commit comments

Comments
 (0)