Files
59704dc34c [otelcol] Fix missing defaults in unredacted print-config (#14752)
**Description**

Fixes an issue where `otelcol print-config --mode=unredacted` omits
default values, causing its output structure to differ significantly
from `redacted` mode.

*Implementation details:*
This PR introduces a new `confmap.WithUnredacted()` `MarshalOption` and
an `unredactedStringer` interface within the `mapstructure` encoder.
This allows the configuration to be marshaled natively without
redaction, preserving all default values while cleanly decoupling the
encoder from `configopaque`. The previous recursive post-processing
workaround has been entirely removed.

**Link to tracking issue**

Fixes #14750

**Testing**

* Removed obsolete tests related to the recursive workaround.
* Updated `TestPrintCommand` in `command_print_test.go` to assert
default values are correctly handled natively in `unredacted` mode.
* Passed `make test` locally.

**Documentation**

* Added `.chloggen` entry.

---------

Signed-off-by: EdgeN8v <[email protected]>
Co-authored-by: Damien Mathieu <[email protected]>
Co-authored-by: Vihas Makwana <[email protected]>
Co-authored-by: Pablo Baeyens <[email protected]>
2026-04-06 12:26:57 +00:00

28 lines
1.1 KiB
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package xconfmap // import "go.opentelemetry.io/collector/confmap/xconfmap"
import (
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/internal"
)
// ExpandedValue represents a configuration value that has been expanded from a template
// (e.g., environment variable substitution). It contains both the parsed value and the
// original string representation.
//
// This type is exposed to allow working with configuration values returned by ToStringMapRaw.
type ExpandedValue = internal.ExpandedValue
// ToStringMapRaw returns the raw configuration map without sanitization.
// This is an experimental API and may change or be removed in future versions.
// The returned map may change at any time without prior notice.
//
// Unlike confmap.Conf.ToStringMap(), this function does not sanitize the map
// by removing expandedValue references. This allows for configmap manipulation
// without destroying internal types.
func ToStringMapRaw(conf *confmap.Conf) map[string]any {
return internal.ToStringMapRaw(conf)
}