diff --git a/.chloggen/remove_withErrorUnused.yaml b/.chloggen/remove_withErrorUnused.yaml new file mode 100755 index 00000000000..43b7df9f4a6 --- /dev/null +++ b/.chloggen/remove_withErrorUnused.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: confmap + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove deprecated `confmap.WithErrorUnused` + +# One or more tracking issues or pull requests related to the change +issues: [9484] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [api] \ No newline at end of file diff --git a/cmd/mdatagen/internal/metadata/generated_config.go b/cmd/mdatagen/internal/metadata/generated_config.go index ac4e46cd178..92937f48dbf 100644 --- a/cmd/mdatagen/internal/metadata/generated_config.go +++ b/cmd/mdatagen/internal/metadata/generated_config.go @@ -15,7 +15,7 @@ func (ms *MetricConfig) Unmarshal(parser *confmap.Conf) error { if parser == nil { return nil } - err := parser.Unmarshal(ms, confmap.WithErrorUnused()) + err := parser.Unmarshal(ms) if err != nil { return err } @@ -59,7 +59,7 @@ func (rac *ResourceAttributeConfig) Unmarshal(parser *confmap.Conf) error { if parser == nil { return nil } - err := parser.Unmarshal(rac, confmap.WithErrorUnused()) + err := parser.Unmarshal(rac) if err != nil { return err } diff --git a/cmd/mdatagen/loader.go b/cmd/mdatagen/loader.go index 322d273e33a..ab558aecb2e 100644 --- a/cmd/mdatagen/loader.go +++ b/cmd/mdatagen/loader.go @@ -124,7 +124,7 @@ func (m *metric) Unmarshal(parser *confmap.Conf) error { if !parser.IsSet("enabled") { return errors.New("missing required field: `enabled`") } - err := parser.Unmarshal(m, confmap.WithErrorUnused()) + err := parser.Unmarshal(m) if err != nil { return err } @@ -253,7 +253,7 @@ func loadMetadata(filePath string) (metadata, error) { } md := metadata{ScopeName: scopeName(filePath), ShortFolderName: shortFolderName(filePath)} - if err := conf.Unmarshal(&md, confmap.WithErrorUnused()); err != nil { + if err := conf.Unmarshal(&md); err != nil { return md, err } diff --git a/cmd/mdatagen/metricdata.go b/cmd/mdatagen/metricdata.go index c3448f1722c..f4515136aae 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, confmap.WithErrorUnused()) + return parser.Unmarshal(d) } 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, confmap.WithErrorUnused()) + return parser.Unmarshal(d) } // TODO: Currently, this func will not be called because of https://github.com/open-telemetry/opentelemetry-collector/issues/6671. Uncomment function and @@ -166,7 +166,7 @@ func (d *sum) Unmarshal(parser *confmap.Conf) error { // if !parser.IsSet("monotonic") { // return errors.New("missing required field: `monotonic`") // } -// return parser.Unmarshal(m, confmap.WithErrorUnused()) +// return parser.Unmarshal(m) // } func (d sum) Type() string { diff --git a/cmd/mdatagen/templates/config.go.tmpl b/cmd/mdatagen/templates/config.go.tmpl index 02f69788334..712602222e7 100644 --- a/cmd/mdatagen/templates/config.go.tmpl +++ b/cmd/mdatagen/templates/config.go.tmpl @@ -19,7 +19,7 @@ func (ms *MetricConfig) Unmarshal(parser *confmap.Conf) error { if parser == nil { return nil } - err := parser.Unmarshal(ms, confmap.WithErrorUnused()) + err := parser.Unmarshal(ms) if err != nil { return err } @@ -57,7 +57,7 @@ func (rac *ResourceAttributeConfig) Unmarshal(parser *confmap.Conf) error { if parser == nil { return nil } - err := parser.Unmarshal(rac, confmap.WithErrorUnused()) + err := parser.Unmarshal(rac) if err != nil { return err } diff --git a/confmap/confmap.go b/confmap/confmap.go index 9817694dd63..9664109f9ab 100644 --- a/confmap/confmap.go +++ b/confmap/confmap.go @@ -54,16 +54,6 @@ type unmarshalOption struct { ignoreUnused bool } -// WithErrorUnused sets an option to error when there are existing -// keys in the original Conf that were unused in the decoding process -// (extra keys). This option is enabled by default and can be disabled with `WithIgnoreUnused`. -// Deprecated: [v0.92.0] this is now enabled by default. Use `WithIgnoreUnused` to disable. -func WithErrorUnused() UnmarshalOption { - return unmarshalOptionFunc(func(uo *unmarshalOption) { - uo.ignoreUnused = false - }) -} - // WithIgnoreUnused sets an option to ignore errors if existing // keys in the original Conf were unused in the decoding process // (extra keys). diff --git a/confmap/confmap_test.go b/confmap/confmap_test.go index 7cfab3fb4cb..9ebb3b20568 100644 --- a/confmap/confmap_test.go +++ b/confmap/confmap_test.go @@ -143,7 +143,7 @@ func TestExpandNilStructPointersHookFuncDefaultNotNilConfigNil(t *testing.T) { assert.Equal(t, &Struct{}, cfg.MapStruct["struct"]) } -func TestUnmarshalWithErrorUnused(t *testing.T) { +func TestUnmarshalWithIgnoreUnused(t *testing.T) { stringMap := map[string]any{ "boolean": true, "string": "this is a string",