Skip to content

Conversation

rsjethani
Copy link
Contributor

The changes add a new NoFile option and the new
fig.ignoreFile field.

Giving this option to Load() will:

  • Disable the default file lookup process
  • The File and Dir option still work as before but
    become ineffective in the presence of NoFile option.

Signed-off-by: Ravi Shekhar Jethani rsjethani@gmail.com

The changes add a new `NoFile` option and the new
`fig.ignoreFile` field.

Giving this option to `Load()` will:
- Disable the default file lookup process
- The `File` and `Dir` option still work as before but
  become ineffective in the presence of `NoFile` option.

Signed-off-by: Ravi Shekhar Jethani <rsjethani@gmail.com>
@rsjethani
Copy link
Contributor Author

Addresses #5

@kkyr
Copy link
Owner

kkyr commented Nov 14, 2021

Thanks for the PR!

I'll allocate some time to go over it in the next few days.

Copy link
Owner

@kkyr kkyr left a comment

Choose a reason for hiding this comment

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

doc.go should also be updated:

  1. Explanation of IgnoreFile under its own heading
  2. Update wording under Environment heading accordingly, since config file is no longer always mandatory.

fig.go Outdated
if err != nil {
return err
if !f.ignoreFile {

Copy link
Owner

Choose a reason for hiding this comment

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

Unnecessary newline

fig_test.go Outdated
@@ -405,6 +405,66 @@ func Test_fig_Load_WithOptions(t *testing.T) {
}
}

func Test_fig_Load_NoFile(t *testing.T) {
t.Run("NOFILE", func(t *testing.T) {
Copy link
Owner

Choose a reason for hiding this comment

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

No need to run a subtest here.

option.go Outdated
// config values only via environment variables.
//
// fig.Load(&cfg, fig.NoFile(), fig.UseEnv("my_app"))
func NoFile() Option {
Copy link
Owner

Choose a reason for hiding this comment

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

I believe IgnoreFile would be a more descriptive name here, since we're telling fig to actually ignore the file (even if it exists).

option.go Outdated
@@ -18,6 +18,19 @@ func File(name string) Option {
}
}

// NoFile returns an option which disables any file lookup
Copy link
Owner

Choose a reason for hiding this comment

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

Period at end of line.

@rsj-ioki
Copy link
Contributor

Thanks for the review, changes added

@rsjethani rsjethani requested a review from kkyr December 26, 2021 12:55
@kkyr
Copy link
Owner

kkyr commented Dec 26, 2021

Please also add a description to doc.go as described in one of my comments above.

@rsjethani
Copy link
Contributor Author

updated docs

@kkyr kkyr merged commit 711af35 into kkyr:master Jan 3, 2022
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