Skip to content
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

Added error checking for env vars and flags #1875

Merged
merged 1 commit into from
Nov 22, 2022
Merged

Conversation

enrichman
Copy link
Member

@enrichman enrichman commented Nov 21, 2022

Removed TODO and added error checking for viper environment variables and flags.

related to #1870 and #1859


Suppressing errors is not a good idea. If anything occurs we should be aware of it.

The problem of the log.Fatal(err) approach is that it's the only viable option in the init() func (that's why I'm not a fan of them). They are used in the Cobra user guide, and that's why this setup is widespread.

But this is something that they don't like as well, and I guess that they are more or less working on it:

@enrichman enrichman requested a review from a team as a code owner November 21, 2022 14:57
@codecov-commenter
Copy link

codecov-commenter commented Nov 21, 2022

Codecov Report

Base: 56.36% // Head: 50.70% // Decreases project coverage by -5.66% ⚠️

Coverage data is based on head (b6ee78d) compared to base (1839df2).
Patch coverage: 83.56% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1875      +/-   ##
==========================================
- Coverage   56.36%   50.70%   -5.67%     
==========================================
  Files         179      179              
  Lines       14454    14497      +43     
==========================================
- Hits         8147     7350     -797     
- Misses       5260     6145     +885     
+ Partials     1047     1002      -45     
Flag Coverage Δ
acceptance-api 36.66% <83.56%> (+2.93%) ⬆️
acceptance-apps 36.36% <83.56%> (+0.10%) ⬆️
acceptance-cli 42.48% <83.56%> (-9.26%) ⬇️
unittests 8.50% <94.64%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
helpers/kubernetes/config/checker.go 54.16% <25.00%> (-5.84%) ⬇️
helpers/tracelog/logger.go 39.39% <25.00%> (-3.94%) ⬇️
internal/duration/duration.go 78.26% <25.00%> (-21.74%) ⬇️
internal/cli/root.go 75.67% <75.00%> (-1.60%) ⬇️
helpers/kubernetes/config/argtoenv.go 100.00% <100.00%> (ø)
helpers/kubernetes/config/config.go 57.14% <100.00%> (+3.29%) ⬆️
internal/cli/server.go 90.74% <100.00%> (+1.85%) ⬆️
internal/cli/settings.go 16.07% <100.00%> (-34.86%) ⬇️
pkg/api/core/v1/models/namespace.go 0.00% <0.00%> (-100.00%) ⬇️
internal/api/v1/configuration/match.go 0.00% <0.00%> (-82.36%) ⬇️
... and 74 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@enrichman enrichman self-assigned this Nov 21, 2022
@enrichman enrichman merged commit 6f96ecc into main Nov 22, 2022
@enrichman enrichman deleted the add-viper-errcheck branch November 22, 2022 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants