-
Notifications
You must be signed in to change notification settings - Fork 1
fix: add defaults for agent config to fully support nested env var overriders #188
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
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.
Orca Security Scan Summary
Status | Check | Issues by priority | |
---|---|---|---|
![]() |
Infrastructure as Code | ![]() ![]() ![]() ![]() |
View in Orca |
![]() |
SAST | ![]() ![]() ![]() ![]() |
View in Orca |
![]() |
Secrets | ![]() ![]() ![]() ![]() |
View in Orca |
![]() |
Vulnerabilities | ![]() ![]() ![]() ![]() |
View in Orca |
if err != nil { | ||
panic(err) | ||
} | ||
var recursiveDfs func(prefix string, defaults map[string]any) |
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 not just recursiveDfs := func(
?
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 need to declare it first since it's recursive, otherwise I can't reference it in the function body.
internal/root/root.go
Outdated
@@ -53,6 +54,11 @@ func InitConfig() { | |||
} | |||
|
|||
viper.AutomaticEnv() // read in environment variables that match | |||
// TODO add this into our next major release to improve our env var naming. | |||
// viper.SetEnvKeyReplacer(strings.NewReplacer(`::`, `_`)) |
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.
we use _ in the actual field names as well, would this work with that? that's why we switched to ::
to begin with
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.
Oh, if the ::
was to avoid ambiguity, then I will just delete this comment. I think that _
is easier to use (ie HOST_MONITORING_ENABLED=true observe-agent start
vs env HOST_MONITORING::ENABLED=true observe-agent start
), but if this was an intentional choice for clarity then let's keep it.
2d9a443
to
e342f95
Compare
Description
Add viper defaults for all agent config settings. Without this, nested env vars will be ignored unless the value is already set in the config. ex:
env HOST_MONITORING::ENABLED=true ./observe-agent start
will be ignored with an empty agent config.