-
Notifications
You must be signed in to change notification settings - Fork 32
Allow providing config values only via environment #9
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
Conversation
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>
Addresses #5 |
Thanks for the PR! I'll allocate some time to go over it in the next few days. |
There was a problem hiding this 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:
- Explanation of
IgnoreFile
under its own heading - 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 { | ||
|
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Thanks for the review, changes added |
Please also add a description to |
updated docs |
The changes add a new
NoFile
option and the newfig.ignoreFile
field.Giving this option to
Load()
will:File
andDir
option still work as before butbecome ineffective in the presence of
NoFile
option.Signed-off-by: Ravi Shekhar Jethani rsjethani@gmail.com