Ensure config structs can be marshaled into YAML
Is your feature request related to a problem? Please describe.
It is possible for structs to contain fields that cannot be marshaled into YAML. We recently went through the process of updating or removing some of these (e.g. https://github.com/open-telemetry/opentelemetry-collector/pull/10310), but there are currently no tests in place to ensure non-marshalable fields will be added in the future.
In particular, I want do so something like this:
// Programmatically-generated config
cfg := otelcol.Config{...}
// Should marshal to YAML
conf := confmap.New()
conf.Marshal(cfg)
// Should be equivalent to cfg
cfg2 := unmarshal(conf)Describe the solution you'd like
Add tests to mdatagen that test that we can marshal/unmarshal all config structs. Ideally, we put the config structs through an iteration of marshaling and unmarshaling to ensure the structs can't easily enter a state where conversion is impossible.
Describe alternatives you've considered
Some kind of integration test that happens in a secondary package could be a possible way to do this, and would forgo the need for a direct confmap dependency in every package that for use only in tests.
Source: open-telemetry/opentelemetry-collector