Files
telemetry/confmap/internal/marshaloption.go
6fe62562a1 [configoptional] Allow wrapping scalar values (#15175)
<!--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]>
2026-05-19 13:58:33 +00:00

32 lines
827 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package internal // import "go.opentelemetry.io/collector/confmap/internal"
type MarshalOption interface {
apply(*MarshalOptions)
}
// MarshalOptions is used by (*Conf).Marshal to toggle unmarshaling settings.
// It is in the `internal` package so experimental options can be added in xconfmap.
type MarshalOptions struct {
// OpaqueUnredacted specifies whether opaque strings should be marshaled unredacted.
OpaqueUnredacted bool
}
type MarshalOptionFunc func(*MarshalOptions)
func (fn MarshalOptionFunc) apply(set *MarshalOptions) {
fn(set)
}
func ApplyMarshalOptions(set *MarshalOptions, opts []MarshalOption) *MarshalOptions {
if set == nil {
set = &MarshalOptions{}
}
for _, opt := range opts {
opt.apply(set)
}
return set
}