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

Change config.Retrieved to be an interface #5305

Closed
wants to merge 1 commit into from

Conversation

bogdandrutu
Copy link
Member

This change will allow to implement support for "retrieving" any type of values, since we can offer implementations of the retrieved for string/etc.

Signed-off-by: Bogdan Drutu bogdandrutu@gmail.com

@bogdandrutu bogdandrutu requested review from a team and codeboten May 3, 2022 17:37
@bogdandrutu
Copy link
Member Author

cc @mx-psi since you review the initial proposal #5198

@codecov
Copy link

codecov bot commented May 3, 2022

Codecov Report

Merging #5305 (b8cee65) into main (ab79681) will decrease coverage by 0.18%.
The diff coverage is 47.05%.

@@            Coverage Diff             @@
##             main    #5305      +/-   ##
==========================================
- Coverage   90.75%   90.56%   -0.19%     
==========================================
  Files         190      190              
  Lines       11422    11442      +20     
==========================================
- Hits        10366    10363       -3     
- Misses        837      858      +21     
- Partials      219      221       +2     
Impacted Files Coverage Δ
config/mapprovider.go 48.64% <33.33%> (-51.36%) ⬇️
config/mapprovider/envmapprovider/mapprovider.go 100.00% <100.00%> (ø)
config/mapprovider/filemapprovider/mapprovider.go 100.00% <100.00%> (ø)
config/mapprovider/yamlmapprovider/mapprovider.go 100.00% <100.00%> (ø)
pdata/internal/common.go 91.82% <0.00%> (-0.75%) ⬇️

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 ab79681...b8cee65. Read the comment docs.

config/mapprovider.go Show resolved Hide resolved
…e values that are not *Map

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
@bogdandrutu bogdandrutu changed the title Change config.Retrieved to be an interface, removes access to deprecated members Change config.Retrieved to be an interface May 18, 2022
Comment on lines +148 to +151
// * cfgMap the Map that will be merged to the given map in the MergeTo.
// * CloseFunc specifies a function to be invoked when the configuration for which it was
// used to retrieve values is no longer in use and should close and release any watchers
// that it may have created.
Copy link
Member

Choose a reason for hiding this comment

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

docs are out of date here and above

func (r *valueRetrieved) AsMap() (*Map, error) {
val, ok := r.value.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("retrieved value (type=%v) cannot be used as a *Map", reflect.TypeOf(r.value))
Copy link
Member

Choose a reason for hiding this comment

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

You can use %T in a format string to get the type

Suggested change
return nil, fmt.Errorf("retrieved value (type=%v) cannot be used as a *Map", reflect.TypeOf(r.value))
return nil, fmt.Errorf("retrieved value (type=%T) cannot be used as a *Map", r.value)

@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2022

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jun 7, 2022
@bogdandrutu
Copy link
Member Author

This is outdated at this point.

@bogdandrutu bogdandrutu closed this Jun 7, 2022
@bogdandrutu bogdandrutu deleted the rmdepprov branch June 7, 2022 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants