-
Notifications
You must be signed in to change notification settings - Fork 3
Fix update of flags from the environment #117
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
adriansmares
left a comment
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 don't think what the original commented requested was clear.
- The environment variables should be used as defaults for the flags - that is fine. It should stay that way everywhere.
- The only cases in which they shouldn't be used as defaults is for secrets.
- The flag value should have a higher priority than the environment variable value. This means that if you provide a secret via the command line and via the environment, the command line one is considered.
| if apiKey := os.Getenv("CHIRPSTACK_API_KEY"); apiKey != "" { | ||
| c.apiKey = apiKey | ||
| } | ||
| if url := os.Getenv("CHIRPSTACK_API_URL"); url != "" { |
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.
Why aren't these non secret parameters built using the defaults here ?
pkg/source/firefly/config.go
Outdated
|
|
||
| if c.appID = os.Getenv("APP_ID"); c.appID == "" { | ||
| return errNoAppID.New() | ||
| if appID := os.Getenv("APP_ID"); appID == "" { |
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.
Same question here.
|
Ok for some reason I always thought that it's a general convention that env takes preference over flags, but that's not the case: https://github.com/spf13/viper#why-viper
I don't really see the reason or value in this. These are not really defaults. It's just echoing the value set. |
The reason is that we don't need for each individual flag manual code that says 'if flag is empty, check environment variable'. Since we don't use |
|
Ok cool. I don't have an argument against it. |
Summary
Refs #112 (comment)
Changes
ttsconfig to match other sources and don't print defaults to the env.Testing
TTS
Check that secrets are not printed.
Others
Check that env is only used when set.
Regressions
Tested export using the
ttssource.ttnv2since that's not so easy.Checklist
CHANGELOG.md.