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

[chore] fix code to support unmarshaling with embedded struct support #31406

Merged
merged 1 commit into from Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/mdatagen/metricdata.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/config.go
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/helper/time.go
Expand Up @@ -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
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/stanza/operator/parser/scope/config_test.go
Expand Up @@ -35,10 +35,6 @@ func TestConfig(t *testing.T) {
return cfg
}(),
},
{
Name: "no_nested",
ExpectErr: true,
},
},
}.Run(t)
}
4 changes: 0 additions & 4 deletions pkg/stanza/operator/parser/severity/config_test.go
Expand Up @@ -46,10 +46,6 @@ func TestUnmarshal(t *testing.T) {
return cfg
}(),
},
{
Name: "no_nested",
ExpectErr: true,
},
},
}.Run(t)
}
4 changes: 0 additions & 4 deletions pkg/stanza/operator/parser/time/config_test.go
Expand Up @@ -49,10 +49,6 @@ func TestUnmarshal(t *testing.T) {
return cfg
}(),
},
{
Name: "no_nested",
ExpectErr: true,
},
},
}.Run(t)
}