Skip to content

Commit

Permalink
fix: require an ftl-project.toml file
Browse files Browse the repository at this point in the history
This is a global requirement across all commands, not scoped
specifically to `ftl serve` or `ftl dev`, because eg. `ftl secret`/`ftl
config`, etc. etc. all require this config file, and it's just
cleaner/safer to do it in one location.

Fixes #1669
  • Loading branch information
alecthomas committed Jun 13, 2024
1 parent 44163b4 commit 832e359
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cmd/ftl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,23 @@ func main() {
logger := log.Configure(os.Stderr, cli.LogConfig)
ctx = log.ContextWithLogger(ctx, logger)

config, err := projectconfig.Load(ctx, cli.ConfigFlag)
configPath := cli.ConfigFlag
if configPath == "" {
var ok bool
configPath, ok = projectconfig.DefaultConfigPath().Get()
if !ok {
kctx.Fatalf("could not determine default config path, place an ftl-project.toml file in your git root directory, use --config=FILE, or set the FTL_CONFIG envar")
}
}

config, err := projectconfig.Load(ctx, configPath)
if err != nil && !errors.Is(err, os.ErrNotExist) {
kctx.Fatalf(err.Error())
}
kctx.Bind(config)

sr := cf.ProjectConfigResolver[cf.Secrets]{Config: cli.ConfigFlag}
cr := cf.ProjectConfigResolver[cf.Configuration]{Config: cli.ConfigFlag}
sr := cf.ProjectConfigResolver[cf.Secrets]{Config: configPath}
cr := cf.ProjectConfigResolver[cf.Configuration]{Config: configPath}
kctx.BindTo(sr, (*cf.Resolver[cf.Secrets])(nil))
kctx.BindTo(cr, (*cf.Resolver[cf.Configuration])(nil))

Expand Down

0 comments on commit 832e359

Please sign in to comment.