-
Notifications
You must be signed in to change notification settings - Fork 2k
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
IsSet() returns false when flags are not set #331
Conversation
2350a42
to
66c1dea
Compare
66c1dea
to
7735e2a
Compare
Just rebased on This solves a small, but real issue. |
7735e2a
to
d1f5a3b
Compare
@benoitmasson This PR doesn't address types where the zero value is a non- |
@sean- Not sure I get your point…
However I may have misunderstood your remark, so feel free to send a test which fails and I will try to fix it. |
d1f5a3b
to
48d4024
Compare
* It seems common enough that flags may be defined from PFlags be retrieved as a sub Viper similar to getting it from Yaml or other configuration structures. This allows flags to be bound one-to-one with how a config file may be structured. * This is partially based on spf13#331 for the find boolean flag * fixes spf13#368
Is this waiting on something specific? |
Can we get this merged please? |
There's a merge conflict, but otherwise this seems ready to merge. Would be awesome to see some movement here! |
/cc @sagikazarmark - PTAL 🙂 |
Added tests for: - nested elements - environment values - flags (currently fails => IsSet() always returns true, due to the default value of the flag)
Default value should be looked for by Get(), but not by IsSet(). This logic should remain inside find(), to make sure that shadowing of keys is handled properly. Fixes Issue spf13#276.
66e51d6
to
f9d0975
Compare
Just rebased, it all looks good. Things have changed since my last update, but this PR is quite light and merging should not be an issue. |
Thanks for the PR and the ping. I'll review this PR shortly. |
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.
Thanks @benoitmasson !
* It seems common enough that flags may be defined from PFlags be retrieved as a sub Viper similar to getting it from Yaml or other configuration structures. This allows flags to be bound one-to-one with how a config file may be structured. * This is partially based on spf13#331 for the find boolean flag * fixes spf13#368
Added flexibility to
find()
function with an extra boolean argument, so that it can be used both byGet()
(to retrieve a value, including flag's default) andIsSet()
(whether the key is set, ignoring flag's default).Fixes #276
Fixes #580
(+ added some tests to enforce this behavior)