Skip to content

Commit

Permalink
fix: remove init-db flag
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Dec 30, 2024
1 parent 57462a4 commit 5ded8c1
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 12 deletions.
6 changes: 6 additions & 0 deletions examples/go/mysql/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ require (
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/block/scaffolder v1.3.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
github.com/danieljoos/wincred v1.2.2 // indirect
Expand Down Expand Up @@ -83,6 +84,7 @@ require (
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jotaen/kong-completion v0.0.6 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.17.11 // indirect
Expand All @@ -98,11 +100,14 @@ require (
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/swaggest/jsonschema-go v0.3.72 // indirect
github.com/swaggest/refl v1.3.0 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/vbatts/tar-split v0.11.3 // indirect
github.com/zalando/go-keyring v0.2.6 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
Expand All @@ -123,6 +128,7 @@ require (
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/tools v0.28.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
Expand Down
16 changes: 16 additions & 0 deletions examples/go/mysql/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions examples/go/postgres/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ require (
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/block/scaffolder v1.3.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
github.com/danieljoos/wincred v1.2.2 // indirect
Expand Down Expand Up @@ -83,6 +84,7 @@ require (
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jotaen/kong-completion v0.0.6 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.17.11 // indirect
Expand All @@ -98,11 +100,14 @@ require (
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/swaggest/jsonschema-go v0.3.72 // indirect
github.com/swaggest/refl v1.3.0 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/vbatts/tar-split v0.11.3 // indirect
github.com/zalando/go-keyring v0.2.6 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
Expand All @@ -123,6 +128,7 @@ require (
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/tools v0.28.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
Expand Down
16 changes: 16 additions & 0 deletions examples/go/postgres/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions frontend/cli/cmd_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ type devCmd struct {
NoServe bool `help:"Do not start the FTL server." default:"false"`
Lsp bool `help:"Run the language server." default:"false"`
ServeCmd serveCommonConfig `embed:""`
InitDB bool `help:"Initialize the database and exit." default:"false"`
languageServer *lsp.Server
Build buildCmd `embed:""`
}

func (d *devCmd) Run(
ctx context.Context,
k *kong.Kong,
kctx *kong.Context,
cm *manager.Manager[configuration.Configuration],
sm *manager.Manager[configuration.Secrets],
projConfig projectconfig.Config,
Expand Down Expand Up @@ -76,13 +74,6 @@ func (d *devCmd) Run(
return KillBackgroundServe(logger)
}

if d.InitDB {
err := dev.SetupPostgres(ctx, optional.Some(d.ServeCmd.DatabaseImage), d.ServeCmd.DBPort, true)
if err != nil {
return fmt.Errorf("failed to setup database: %w", err)
}
return nil
}
statusManager := terminal.FromContext(ctx)
defer statusManager.Close()
starting := statusManager.NewStatus("\u001B[92mStarting FTL Server 🚀\u001B[39m")
Expand Down
8 changes: 5 additions & 3 deletions internal/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/block/ftl/internal/flock"
"github.com/block/ftl/internal/log"
"github.com/block/ftl/internal/projectconfig"
"github.com/block/ftl/internal/terminal"
)

var dockerClient = once.Once(func(ctx context.Context) (*client.Client, error) {
Expand Down Expand Up @@ -73,9 +74,10 @@ func Pull(ctx context.Context, imageName string) error {
}
defer reader.Close()

logger := log.FromContext(ctx).Scope(imageName)
w := logger.WriterAt(log.Info)
if err := jsonmessage.DisplayJSONMessagesStream(reader, w, 0, false, nil); err != nil {
sm := terminal.FromContext(ctx)
statusLine := sm.NewStatus("Pulling image" + imageName)
defer statusLine.Close()
if err := jsonmessage.DisplayJSONMessagesStream(reader, terminal.StatusLineAsWriter(statusLine), 0, false, nil); err != nil {
return fmt.Errorf("failed to display pull messages: %w", err)
}

Expand Down
24 changes: 24 additions & 0 deletions internal/terminal/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io"
"os"
"os/signal"
"slices"
Expand Down Expand Up @@ -524,3 +525,26 @@ func LaunchEmbeddedConsole(ctx context.Context, k *kong.Kong, binder KongContext
}()
}
}

var _ io.Writer = &statusLineWriter{}

func StatusLineAsWriter(status StatusLine) io.Writer {
return &statusLineWriter{status: status}
}

type statusLineWriter struct {
status StatusLine
line string
}

func (s *statusLineWriter) Write(p []byte) (n int, err error) {
for _, c := range p {
if c == '\n' {
s.status.SetMessage(s.line)
s.line = ""
} else {
s.line += string(c)
}
}
return len(p), nil
}

0 comments on commit 5ded8c1

Please sign in to comment.