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

Start hiding viper in public APIs #2806

Merged
merged 1 commit into from
Mar 25, 2021

Conversation

bogdandrutu
Copy link
Member

The new Parser struct is mostly a wrapper around Viper with bunch of fixes.

Signed-off-by: Bogdan Drutu [email protected]

@bogdandrutu bogdandrutu requested a review from a team March 25, 2021 19:08
@codecov
Copy link

codecov bot commented Mar 25, 2021

Codecov Report

Merging #2806 (609d511) into main (06ea2c6) will increase coverage by 0.02%.
The diff coverage is 89.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2806      +/-   ##
==========================================
+ Coverage   91.64%   91.67%   +0.02%     
==========================================
  Files         294      294              
  Lines       15637    15640       +3     
==========================================
+ Hits        14331    14338       +7     
+ Misses        896      891       -5     
- Partials      410      411       +1     
Impacted Files Coverage Δ
service/application.go 76.31% <75.00%> (-0.21%) ⬇️
config/parser.go 85.71% <83.33%> (ø)
config/configparser/config.go 100.00% <100.00%> (+1.37%) ⬆️
config/configtest/configtest.go 100.00% <100.00%> (ø)
receiver/hostmetricsreceiver/factory.go 87.01% <100.00%> (+0.17%) ⬆️
service/set_flag.go 80.95% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06ea2c6...609d511. Read the comment docs.

v *viper.Viper,
factories component.Factories,
) (*configmodels.Config, error) {
func Parse(v *config.Parser, factories component.Factories) (*configmodels.Config, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
func Parse(v *config.Parser, factories component.Factories) (*configmodels.Config, error) {
func Parse(p *config.Parser, factories component.Factories) (*configmodels.Config, error) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: names are a bit confusing. If this is Parse func, then why is it accepting a Parser? Is Parser doing parsing or this function is doing parsing?

Maybe this package should be named configloader instead of configparser and the function is Load instead of Parse?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted to Load. Will update the package later.

@@ -120,33 +116,33 @@ func Load(

// Start with the service extensions.

extensions, err := loadExtensions(v.GetStringMap(extensionsKeyName), factories.Extensions)
extensions, err := loadExtensions(cast.ToStringMap(v.Get(extensionsKeyName)), factories.Extensions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the final destination? Are we going to get rid of cast.ToStringMap?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I need it, but will followup. I want to start with a minimal API for Parser

config/configparser/config_test.go Outdated Show resolved Hide resolved
config/configparser/config_test.go Outdated Show resolved Hide resolved
The new Parser struct is mostly a wrapper around Viper with bunch of fixes.

Signed-off-by: Bogdan Drutu <[email protected]>
@bogdandrutu bogdandrutu merged commit 9431223 into open-telemetry:main Mar 25, 2021
@bogdandrutu bogdandrutu deleted the hideviper branch March 25, 2021 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants