diff --git a/cmd/mdatagen/metricdata.go b/cmd/mdatagen/metricdata.go index f4515136aaedb..5bf77985cc95e 100644 --- a/cmd/mdatagen/metricdata.go +++ b/cmd/mdatagen/metricdata.go @@ -125,7 +125,7 @@ func (d *gauge) Unmarshal(parser *confmap.Conf) error { if err := d.MetricValueType.Unmarshal(parser); err != nil { return err } - return parser.Unmarshal(d) + return parser.Unmarshal(d, confmap.WithIgnoreUnused()) } func (d gauge) Type() string { @@ -155,7 +155,7 @@ func (d *sum) Unmarshal(parser *confmap.Conf) error { if err := d.MetricValueType.Unmarshal(parser); err != nil { return err } - return parser.Unmarshal(d) + return parser.Unmarshal(d, confmap.WithIgnoreUnused()) } // TODO: Currently, this func will not be called because of https://github.com/open-telemetry/opentelemetry-collector/issues/6671. Uncomment function and diff --git a/pkg/stanza/operator/config.go b/pkg/stanza/operator/config.go index 49fc40271a49e..f9934c6a06ffc 100644 --- a/pkg/stanza/operator/config.go +++ b/pkg/stanza/operator/config.go @@ -107,7 +107,7 @@ func (c *Config) Unmarshal(component *confmap.Conf) error { } builder := builderFunc() - if err := component.Unmarshal(builder); err != nil { + if err := component.Unmarshal(builder, confmap.WithIgnoreUnused()); err != nil { return fmt.Errorf("unmarshal to %s: %w", typeString, err) } diff --git a/pkg/stanza/operator/helper/time.go b/pkg/stanza/operator/helper/time.go index b6a0bc787b48e..f9326c73dd183 100644 --- a/pkg/stanza/operator/helper/time.go +++ b/pkg/stanza/operator/helper/time.go @@ -48,7 +48,7 @@ type TimeParser struct { // Unmarshal starting from default settings func (t *TimeParser) Unmarshal(component *confmap.Conf) error { cfg := NewTimeParser() - err := component.Unmarshal(&cfg) + err := component.Unmarshal(&cfg, confmap.WithIgnoreUnused()) if err != nil { return err } diff --git a/pkg/stanza/operator/parser/scope/config_test.go b/pkg/stanza/operator/parser/scope/config_test.go index e7509787aedb1..a3bcb83cd2ccd 100644 --- a/pkg/stanza/operator/parser/scope/config_test.go +++ b/pkg/stanza/operator/parser/scope/config_test.go @@ -35,10 +35,6 @@ func TestConfig(t *testing.T) { return cfg }(), }, - { - Name: "no_nested", - ExpectErr: true, - }, }, }.Run(t) } diff --git a/pkg/stanza/operator/parser/severity/config_test.go b/pkg/stanza/operator/parser/severity/config_test.go index 905092a417380..18fa853a485d5 100644 --- a/pkg/stanza/operator/parser/severity/config_test.go +++ b/pkg/stanza/operator/parser/severity/config_test.go @@ -46,10 +46,6 @@ func TestUnmarshal(t *testing.T) { return cfg }(), }, - { - Name: "no_nested", - ExpectErr: true, - }, }, }.Run(t) } diff --git a/pkg/stanza/operator/parser/time/config_test.go b/pkg/stanza/operator/parser/time/config_test.go index 1b1b5ec7e2b5d..c40c2596f3194 100644 --- a/pkg/stanza/operator/parser/time/config_test.go +++ b/pkg/stanza/operator/parser/time/config_test.go @@ -49,10 +49,6 @@ func TestUnmarshal(t *testing.T) { return cfg }(), }, - { - Name: "no_nested", - ExpectErr: true, - }, }, }.Run(t) }