Skip to content

Commit

Permalink
fix issue with context for language plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman committed Jan 7, 2025
1 parent 3740ada commit 05c6e70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
25 changes: 14 additions & 11 deletions frontend/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ func main() {

app := createKongApplication(&cli, csm)

err := kong.ApplyDefaults(&cli.LogConfig)
app.FatalIfErrorf(err)

pluginCtx := log.ContextWithLogger(ctx, log.Configure(os.Stderr, cli.LogConfig))
languagePlugin, err := languageplugin.PrepareNewCmd(pluginCtx, app, os.Args[1:])
app.FatalIfErrorf(err)
addToExit(app, func(code int) {
// Kill the plugin when the app exits due to an error, or after showing help.
languagePlugin.Close()
})

kctx, err := app.Parse(os.Args[1:])
app.FatalIfErrorf(err)

Expand All @@ -111,6 +122,9 @@ func main() {
defer trace.Stop()
}

// Plugins take time to launch, so we bind the "ftl new" plugin to the kong context.
kctx.Bind(languagePlugin)

if !cli.Plain {
sm := terminal.NewStatusManager(ctx)
csm.statusManager = optional.Some(sm)
Expand All @@ -136,17 +150,6 @@ func main() {
logger := log.Configure(os.Stderr, cli.LogConfig)
ctx = log.ContextWithLogger(ctx, logger)

// Dynamically update the kong app with language specific flags for the "ftl new" command.
languagePlugin, err := languageplugin.PrepareNewCmd(log.ContextWithLogger(ctx, logger), app, os.Args[1:])
app.FatalIfErrorf(err)
addToExit(app, func(code int) {
// Kill the plugin when the app exits due to an error, or after showing help.
languagePlugin.Close()
})

// Plugins take time to launch, so we bind the "ftl new" plugin to the kong context.
kctx.Bind(languagePlugin)

if cli.Insecure {
logger.Warnf("--insecure skips TLS certificate verification")
}
Expand Down
2 changes: 1 addition & 1 deletion jvm-runtime/jvm_hot_reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestLifecycleJVM(t *testing.T) {
in.WithDevMode(),
in.GitInit(),
in.Exec("rm", "ftl-project.toml"),
in.Exec("ftl", "init", "test"),
in.Exec("ftl", "init", "test", "."),
in.IfLanguage("java", in.Exec("ftl", "new", "java", "echo")),
in.IfLanguage("kotlin", in.Exec("ftl", "new", "kotlin", "echo")),
in.WaitWithTimeout("echo", time.Minute),
Expand Down

0 comments on commit 05c6e70

Please sign in to comment.