From f5cb63ded8c46075f3491092b5af5b083997950e Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Wed, 18 Dec 2024 10:57:33 +1100 Subject: [PATCH] chore: more DB cleanup (#3803) Co-authored-by: github-actions[bot] --- backend/admin/service.go | 9 --------- backend/controller/controller.go | 5 ----- cmd/ftl-admin/main.go | 2 -- cmd/ftl-controller/main.go | 2 -- cmd/ftl-initdb/main.go | 28 ---------------------------- frontend/cli/main.go | 2 -- 6 files changed, 48 deletions(-) delete mode 100644 cmd/ftl-initdb/main.go diff --git a/backend/admin/service.go b/backend/admin/service.go index 32b0ee101..6692c6cfc 100644 --- a/backend/admin/service.go +++ b/backend/admin/service.go @@ -7,7 +7,6 @@ import ( "net/url" "connectrpc.com/connect" - "github.com/alecthomas/kong" _ "github.com/jackc/pgx/v5/stdlib" ftlv1 "github.com/block/ftl/backend/protos/xyz/block/ftl/v1" @@ -17,7 +16,6 @@ import ( "github.com/block/ftl/internal/configuration" "github.com/block/ftl/internal/configuration/manager" "github.com/block/ftl/internal/configuration/providers" - "github.com/block/ftl/internal/dsn" "github.com/block/ftl/internal/log" "github.com/block/ftl/internal/rpc" "github.com/block/ftl/internal/schema/schemaeventsource" @@ -27,12 +25,6 @@ type Config struct { Bind *url.URL `help:"Socket to bind to." default:"http://127.0.0.1:8896" env:"FTL_BIND"` } -func (c *Config) SetDefaults() { - if err := kong.ApplyDefaults(c, kong.Vars{"dsn": dsn.PostgresDSN("ftl")}); err != nil { - panic(err) - } -} - type AdminService struct { schr SchemaRetriever cm *manager.Manager[configuration.Configuration] @@ -78,7 +70,6 @@ func Start( sm *manager.Manager[configuration.Secrets], schr SchemaRetriever, ) error { - config.SetDefaults() logger := log.FromContext(ctx).Scope("admin") svc := NewAdminService(cm, sm, schr) diff --git a/backend/controller/controller.go b/backend/controller/controller.go index 6427fbaee..c8e9f81e4 100644 --- a/backend/controller/controller.go +++ b/backend/controller/controller.go @@ -17,7 +17,6 @@ import ( "time" "connectrpc.com/connect" - "github.com/alecthomas/kong" "github.com/alecthomas/types/optional" "github.com/alecthomas/types/result" "github.com/jackc/pgx/v5" @@ -44,7 +43,6 @@ import ( "github.com/block/ftl/common/sha256" "github.com/block/ftl/common/slices" "github.com/block/ftl/internal/deploymentcontext" - "github.com/block/ftl/internal/dsn" "github.com/block/ftl/internal/log" ftlmaps "github.com/block/ftl/internal/maps" "github.com/block/ftl/internal/model" @@ -75,9 +73,6 @@ type Config struct { } func (c *Config) SetDefaults() { - if err := kong.ApplyDefaults(c, kong.Vars{"dsn": dsn.PostgresDSN("ftl")}); err != nil { - panic(err) - } if c.Advertise == nil { c.Advertise = c.Bind } diff --git a/cmd/ftl-admin/main.go b/cmd/ftl-admin/main.go index 43df51612..c01f737fe 100644 --- a/cmd/ftl-admin/main.go +++ b/cmd/ftl-admin/main.go @@ -17,7 +17,6 @@ import ( "github.com/block/ftl/internal/configuration/manager" "github.com/block/ftl/internal/configuration/providers" "github.com/block/ftl/internal/configuration/routers" - "github.com/block/ftl/internal/dsn" "github.com/block/ftl/internal/log" "github.com/block/ftl/internal/observability" "github.com/block/ftl/internal/rpc" @@ -40,7 +39,6 @@ func main() { kong.UsageOnError(), kong.Vars{ "version": ftl.FormattedVersion, - "dsn": dsn.PostgresDSN("ftl"), }, ) diff --git a/cmd/ftl-controller/main.go b/cmd/ftl-controller/main.go index e6b854edd..1114c35fd 100644 --- a/cmd/ftl-controller/main.go +++ b/cmd/ftl-controller/main.go @@ -14,7 +14,6 @@ import ( "github.com/block/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect" "github.com/block/ftl/backend/timeline" _ "github.com/block/ftl/internal/automaxprocs" // Set GOMAXPROCS to match Linux container CPU quota. - "github.com/block/ftl/internal/dsn" "github.com/block/ftl/internal/log" "github.com/block/ftl/internal/observability" "github.com/block/ftl/internal/rpc" @@ -39,7 +38,6 @@ func main() { kong.UsageOnError(), kong.Vars{ "version": ftl.FormattedVersion, - "dsn": dsn.PostgresDSN("ftl"), }, ) cli.ControllerConfig.SetDefaults() diff --git a/cmd/ftl-initdb/main.go b/cmd/ftl-initdb/main.go deleted file mode 100644 index 1d8cf29de..000000000 --- a/cmd/ftl-initdb/main.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "context" - "os" - - "github.com/alecthomas/kong" - - "github.com/block/ftl/internal/dev" - "github.com/block/ftl/internal/dsn" - "github.com/block/ftl/internal/log" -) - -var cli struct { - log.Config - Recreate bool `help:"Drop and recreate the database."` - DSN string `help:"Postgres DSN." default:"${dsn}" env:"FTL_DSN"` -} - -func main() { - kctx := kong.Parse(&cli, kong.Vars{ - "dsn": dsn.PostgresDSN("ftl"), - }) - ctx := log.ContextWithLogger(context.Background(), log.Configure(os.Stderr, cli.Config)) - conn, err := dev.CreateForDevel(ctx, cli.DSN, cli.Recreate) - kctx.FatalIfErrorf(err) - conn.Close() -} diff --git a/frontend/cli/main.go b/frontend/cli/main.go index 925ce8ea0..78bf83ac3 100644 --- a/frontend/cli/main.go +++ b/frontend/cli/main.go @@ -29,7 +29,6 @@ import ( "github.com/block/ftl/internal/configuration" "github.com/block/ftl/internal/configuration/manager" "github.com/block/ftl/internal/configuration/providers" - "github.com/block/ftl/internal/dsn" "github.com/block/ftl/internal/log" "github.com/block/ftl/internal/profiles" "github.com/block/ftl/internal/projectconfig" @@ -195,7 +194,6 @@ func createKongApplication(cli any, csm *currentStatusManager) *kong.Kong { "arch": runtime.GOARCH, "numcpu": strconv.Itoa(runtime.NumCPU()), "gitroot": gitRoot, - "dsn": dsn.PostgresDSN("ftl"), }, kong.Exit(func(code int) { if sm, ok := csm.statusManager.Get(); ok {