Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Third party configuration structs, such as those used in the Prometheus receiver, use YAML struct tags that are necessary for
confmap
to understand if we want to be able to marshal YAML. In particular, in(*Conf).ToStringMap
, we convert structs to a Map object, where ignoring flags likeomitempty
orsquash
causes the map to have a different structure than it would if we calledyaml.Marshal
on the same struct.This PR allows
ToStringMap
to readomitempty
andinline
when struct fields have been annotated with theyaml
tag. These are 2/3 of the flags theyaml
tag supports: https://pkg.go.dev/gopkg.in/yaml.v3#Marshal.Caveats:
yaml:",squash"
andmapstructure:",inline"
will be possible now. I figure that allowing any valid flag regardless of the tag that it applies to is okay (we also supportremain
as an alias) and won't incur any issues, but if we are concerned about conflicts or stability guarantees, I can enforce a stricter schema for which tags support which flags.json
tag for now since we don't support JSON the way we support YAML, but I can add support for it here if we'd like.Required for #10139.