Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error out if specified config doesn't exist, fixes #1347 #1485

Merged
merged 2 commits into from
May 15, 2024

Conversation

safeer
Copy link
Contributor

@safeer safeer commented May 15, 2024

No description provided.

@safeer safeer self-assigned this May 15, 2024
@safeer safeer requested a review from a team May 15, 2024 01:02
@alecthomas alecthomas mentioned this pull request May 15, 2024
@@ -81,7 +80,7 @@ func main() {
ctx = log.ContextWithLogger(ctx, logger)

config, err := projectconfig.LoadConfig(ctx, cli.ConfigFlag)
if err != nil && !errors.Is(err, os.ErrNotExist) {
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The semantics are a little more involved than this will allow for:

  1. If no config is passed on the CLI, we should try to load ftl-project.toml from the root of the repo, but if it doesn't exist that's okay.
  2. If a config is passed explicitly on the command-line, and doesn't exist, this should error.

The simplest way to do this is probably to just check if cli.ConfigFlag == ""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably missing something, but I tried these cases with the following results:

  1. No config passed to CLI and ftl-project.toml exists in the git root: succeeds, has populated Config.
  2. No config passed to CLI and ftl-project.toml doesn't exist in the git root: succeeds, has empty Config.
  3. Config passed to CLI that doesn't exist: error.

Relevant code is in ConfigPaths which returns the config passed to CLI if it exists, the ftl-project.toml in the git root if it exists, otherwise an empty slice. The subsequent call to Merge fails if a path doesn't exist, but it's never provided a nonexistent ftl-project.toml in the git root.

I went down the path of testing by mocking out GetDefaultConfigPath() but that got unwieldy for this change 😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah awesome, apologies I forgot about that code in ConfigPaths, you're 100% right! LGTM

Copy link
Contributor

@deniseli deniseli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!!! :D

@safeer safeer merged commit 57659f3 into main May 15, 2024
10 checks passed
@safeer safeer deleted the config-non-existent-error branch May 15, 2024 21:33
alecthomas added a commit that referenced this pull request May 16, 2024
alecthomas added a commit that referenced this pull request May 16, 2024
…sts (#1504)

See
https://github.com/TBD54566975/ftl/actions/runs/9102976431/job/25023813425

I'm going to pull the integration tests into PR CI, unfortunately it's
really opaque when it only runs on main.

Revert "fix: error out if specified config doesn't exist, fixes #1347
(#1485)"

This reverts commit 57659f3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants