-
Notifications
You must be signed in to change notification settings - Fork 288
Allow config.FromEnv() to enrich an existing config object #436
Allow config.FromEnv() to enrich an existing config object #436
Conversation
Added an other method with config receiver and modified the existing method to call the method with config receiver. Resolves: 430 Signed-off-by: vineeth <vineeth.pothulapati@aquasec.com>
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 for the PR.
I think this change is not enough though. If you look at the end of this function, samplerConfigFromEnv()
and reporterConfigFromEnv()
completely override c.Sampler
and c.Reporter
. Those helper functions also need to be changed to allow inflating the existing configurations.
If you add unit tests for config + env, you'd see it.
…tests. Signed-off-by: vineeth <vineeth.pothulapati@aquasec.com>
assert.Equal(t, false, cfg.Disabled) | ||
assert.Equal(t, true, cfg.RPCMetrics) | ||
assert.Equal(t, "KEY", cfg.Tags[0].Key) | ||
assert.Equal(t, "VALUE", cfg.Tags[0].Value) |
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 suggest to change this test to be more comprehensive, as follows:
- manually initialize Config struct (as you do already)
- do not set any env vars, just call
cfg.FromEnv
and assert that the values remained as configured - set env vars, call cfg.FromEnv again
- assert that values changed
Right now the test is missing step 2.
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 added the required validation in the unit test.
… tests Signed-off-by: vineeth <vineeth.pothulapati@aquasec.com> made chnages to support allow FromEnv for sampler and reporter + Unit tests Signed-off-by: vineeth <vineeth.pothulapati@aquasec.com>
Signed-off-by: vineeth <vineeth.pothulapati@aquasec.com>
Signed-off-by: vineeth <vineeth.pothulapati@aquasec.com>
Signed-off-by: vineeth <vineeth.pothulapati@aquasec.com>
Signed-off-by: vineeth <vineeth.pothulapati@aquasec.com>
Thank you! |
Which problem is this PR solving?
Short description of the changes
Signed-off-by: vineeth vineeth.pothulapati@aquasec.com
Resolves: #430