Skip to content

Commit

Permalink
[chore] fix code to support unmarshaling with embedded struct support (
Browse files Browse the repository at this point in the history
…#31406)

**Description:**
Code changes required to make
open-telemetry/opentelemetry-collector#9635
pass.
  • Loading branch information
atoulme authored Feb 27, 2024
1 parent 2b74c37 commit 76f52c5
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/mdatagen/metricdata.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ func TestUnmarshal(t *testing.T) {
return cfg
}(),
},
{
Name: "no_nested",
ExpectErr: true,
},
},
}.Run(t)
}

0 comments on commit 76f52c5

Please sign in to comment.