Files
38e1bad609 Restrict characters in environment variable names (#10183)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Restricts Environment Variable names according to the
[restrictions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/file-configuration.md#environment-variable-substitution)
published by the OpenTelemetry Configuration Working Group. Changes both
the expand converter and the env provider. Defines one regex to be used
for both of these.

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes
https://github.com/open-telemetry/opentelemetry-collector/issues/9531

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Unit tests

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Pablo Baeyens <[email protected]>
2024-05-24 11:13:56 +02:00

11 lines
293 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package envvar // import "go.opentelemetry.io/collector/confmap/internal/envvar"
import "regexp"
const ValidationPattern = `^[a-zA-Z_][a-zA-Z0-9_]*$`
var ValidationRegexp = regexp.MustCompile(ValidationPattern)