-
Notifications
You must be signed in to change notification settings - Fork 101
Check for deprecated/unknown environment variables #1342
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1342 +/- ##
==========================================
+ Coverage 84.88% 84.89% +0.01%
==========================================
Files 100 100
Lines 14520 14547 +27
==========================================
+ Hits 12325 12350 +25
- Misses 1734 1735 +1
- Partials 461 462 +1
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
} | ||
|
||
func checkDeprecatedEnvVars() { | ||
allViperKeys := make(map[string]struct{}) |
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.
Is the map structure necessary here? From what I see we could use a []string and use slices.Contains
to determine if it's in the list.
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 chose the map over slices as it will be the most performant and scalable solution. In slices, the time taken would be leaner O(n), whereas in a map, it will be constant O(1).
} | ||
} | ||
|
||
func runDeprecatedEnvVarsTest(t *testing.T, tc deprecatedEnvVarsTest) { |
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.
Can this instead just be done inside the unit tests instead of splitting it up
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.
That increases the Cyclomatic complexity of the Test function.
assert.Equal(t, expected, result) | ||
} | ||
|
||
type deprecatedEnvVarsTest struct { |
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.
Can this be moved into the test
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 had to define it outside as the linter gives error if we have more than 5 parameter in a function call.
Implemented a function to validate the environment variables passed are part of the new v3 allowed variables if not it should throw a warning message.
Checklist
Before creating a PR, run through this checklist and mark each as complete.
CONTRIBUTING
documentmake install-tools
and have attached any dependency changes to this pull requestREADME.md
)