Skip to content

WIP do not merge - optional config fields #10260

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

Closed
wants to merge 22 commits into from

Conversation

yurishkuro
Copy link
Member

Description

Experiment with support optional config structs

Link to tracking issue

#10266

Testing

Documentation

Signed-off-by: Yuri Shkuro <[email protected]>
@yurishkuro yurishkuro requested review from a team and dmitryax May 30, 2024 00:30
@yurishkuro yurishkuro marked this pull request as draft May 30, 2024 00:31
Copy link
Contributor

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

Copy link
Contributor

github-actions bot commented Jul 4, 2024

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

@evan-bradley
Copy link
Contributor

@yurishkuro Sorry for the really long delay in getting to this. I still think this approach is the best way to handle optional config fields.

If there were tests in the confmap package to test this with config unmarshaling, I think it would be ready to come out of draft.

@yurishkuro
Copy link
Member Author

@evan-bradley tests wouldn't be a problem, but I ran into a roadblock that I described in #10266 (comment)

@yurishkuro
Copy link
Member Author

WithDefault[T]() was a good idea from @mx-psi, but it didn't work either. When an item is defined in YAML but without any value, i.e. item: with no content, then mapstructure treats the value as nil, and does not perform any processing. As a result, the custom Unmarshal() is still not being called.

See test https://github.com/open-telemetry/opentelemetry-collector/pull/10260/files#diff-24c5961a7871021bd9801008aa5f1fad72efd43f8783a00c7d09dc52c4c64e0dR81

I opened a ticket upstream go-viper/mapstructure#37

Copy link
Contributor

github-actions bot commented Aug 6, 2024

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 Aug 6, 2024
@yurishkuro
Copy link
Member Author

keep

Copy link
Contributor

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 Aug 22, 2024
@mx-psi
Copy link
Member

mx-psi commented Aug 22, 2024

I'll have time to look into this next week, apologies for the delay

@github-actions github-actions bot removed the Stale label Aug 23, 2024
@yurishkuro
Copy link
Member Author

Pending upstream fix go-viper/mapstructure#42

Copy link
Contributor

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

@evan-bradley
Copy link
Contributor

@yurishkuro Just checking in, any updates on this? I have some time to dig into it this week, let me know if there's anything you'd like me to investigate.

Copy link
Contributor

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

@mahadzaryab1
Copy link
Contributor

I've got a PR for the upstream patch open at go-viper/mapstructure#52. To test this patch out, I believe we'll need to re-write the existing hooks in confmap to return reflect.Value instead of the actual values to be able to decode nil values.

Copy link
Contributor

github-actions bot commented Dec 2, 2024

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 Dec 2, 2024
@yurishkuro yurishkuro removed the Stale label Dec 4, 2024
Copy link
Contributor

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

@github-actions github-actions bot added Stale and removed Stale labels Dec 19, 2024
Copy link
Contributor

github-actions bot commented Jan 6, 2025

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

@github-actions github-actions bot added Stale and removed Stale labels Jan 6, 2025
Copy link
Contributor

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 Jan 26, 2025
Copy link
Contributor

github-actions bot commented Feb 9, 2025

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Feb 9, 2025
github-merge-queue bot pushed a commit that referenced this pull request May 13, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

<!-- Issue number if applicable -->

Enables `DecoderConfig.DecodeNil` 


#### Link to tracking issue

Taken from #10260
Updates #12981
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.

5 participants