mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Allow `configoptional.Optional` to wrap scalar values using new interfaces designed specifically to handle similar wrappers around scalar values. Follow up to https://github.com/open-telemetry/opentelemetry-collector/pull/13524. --------- Co-authored-by: Jade Guiton <[email protected]>
32 lines
792 B
Go
32 lines
792 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package internal // import "go.opentelemetry.io/collector/confmap/internal"
|
|
|
|
type UnmarshalOption interface {
|
|
apply(*UnmarshalOptions)
|
|
}
|
|
|
|
// UnmarshalOptions is used by (*Conf).Unmarshal to toggle unmarshaling settings.
|
|
// It is in the `internal` package so experimental options can be added in xconfmap.
|
|
type UnmarshalOptions struct {
|
|
IgnoreUnused bool
|
|
ForceUnmarshaler bool
|
|
}
|
|
|
|
type UnmarshalOptionFunc func(*UnmarshalOptions)
|
|
|
|
func (fn UnmarshalOptionFunc) apply(set *UnmarshalOptions) {
|
|
fn(set)
|
|
}
|
|
|
|
func ApplyUnmarshalOptions(set *UnmarshalOptions, opts []UnmarshalOption) *UnmarshalOptions {
|
|
if set == nil {
|
|
set = &UnmarshalOptions{}
|
|
}
|
|
for _, opt := range opts {
|
|
opt.apply(set)
|
|
}
|
|
return set
|
|
}
|