-
Notifications
You must be signed in to change notification settings - Fork 51
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
backend/flag: error when config is partial #63
Comments
In #67, the `isFlagSet` logic was changed so that it always returned true, so even unmentioned flags would override previously set values. This PR fixes that issue (fixes #79) and also changes the flag tests to be somewhat more flexible and test this specific issue. I haven't made any wider fixes because the concept of using command-line flags as a backend is fundamentally broken in a way that cannot be fixed (see #63), so will probably be removed in a future major version release of confita.
I seem to have run into this issue as well. Is it possible to have multiple independent Confita configuration structures, and have them parse flags in a manner that does not error when they are loaded separately? It appears like the flags backend when executing the LoadStruct command returns the result of flag.Parse, which will throw an error if a flag is not found in the flag set, which is then returned on line 202 of config.go. If the error is a flag not being found on the configuration struct, could operations continue instead of returning? It does seem like this could be difficult based on how the standard library parses flags, however. |
With confita, it's usual to use Load on a struct which doesn't contain all the possible configuration information. For example, we might require information on just the configuration required by a single component.
Unfortunately this does not work well with the flags backend, because it's not possible to parse command line flags correctly without knowing all the possible flags.
This code demonstrates the issue: https://play.golang.org/p/rxws8K5Noxb
The text was updated successfully, but these errors were encountered: