<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
<!-- Issue number if applicable -->
Marks `confmap.strictlyTypedInput` as stable.
#### Link to tracking issue
Fixes#10552
Blocked by:
- #10794
- #10795
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
<!-- Issue number if applicable -->
Removes original string representation if invalid.
#### Link to tracking issue
Fixes#10787
<!--Describe what testing was performed and which tests were added.-->
#### Testing
<!--Describe the documentation added.-->
Added e2e test cases
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
<!-- Issue number if applicable -->
- Adds new `expandedValue` struct that holds the original string
representation if available for values resolved from a provider.
- Removes any mention of `expandedValue` in the public API by adding a
`sanitize` step before returning any `Get`s or `ToStringMap`s.
- Adds new decoding hook that checks if the target field is of `string`
type and uses the string representation in that case.
#### Link to tracking issue
Fixes#10605, Fixes#10405, Fixes#10659
<!--Describe what testing was performed and which tests were added.-->
#### Testing
<!--Describe the documentation added.-->
This changes the behavior in some cases, I update the test cases.
#### Documentation
<!--Please delete paragraphs that you did not use before submitting.-->
| ENV value | ${ENV} before unification | ${ENV} in v0.105.0 (also
${env:ENV} before unification) | Value after this PR |
|----------------------------|----------------------------|---------------------------------------------------------|----------------------------|
| foo\nbar | foo\nbar | foo bar | foo\nbar |
| 1111:1111:1111:1111:1111:: | 1111:1111:1111:1111:1111:: | **Error** |
1111:1111:1111:1111:1111:: |
| "0123" | "0123" | 0123 | "0123" |
#### Description
Bumps the limit of how much recursion we allow. This check is also
gating non-recursive expansions. We probably could separate these
concerns, but thats work that isn't really worthwhile, a simple constant
bump is simple and will cover most users. For the rest, there are
workarounds.
<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes
https://github.com/open-telemetry/opentelemetry-collector/issues/10617
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Fixes#10569. However, I think it's fine to just close the issue as
wontfix and not do this.
#### Description
When we promoted `confmap.unifyEnvVarExpansion` to beta, we found that
the new expansion logic in `confmap` wasn't handling escaping of `$$`
like it is supposed to. This PR fixes that bug, but adding escaping
logic for `$$`.
@azunna1 this fixes the bug you mentioned in
https://github.com/open-telemetry/opentelemetry-collector/pull/10435
around the metricstransformprocessor:
```yaml
metricstransform:
transforms:
- include: '^k8s\.(.*)\.(.*)$$'
match_type: regexp
action: update
new_name: 'kubernetes.$${1}.$${2}'
- include: '^container_([0-9A-Za-z]+)_([0-9A-Za-z]+)_.*'
match_type: regexp
action: update
new_name: 'container.$${1}.$${2}'
```
#### Testing
Added new unit tests explicitly for escaping logic
#### Description
Create new internal module `internal/featuregates`.
This will be useful for importing feature gates while not creating a
dependency cycle.
I intend to use this for importing `confmap.strictlyTypedInput` in
`otelcol` in a follow up PR.
#### Description
<!-- Issue number if applicable -->
- Add `confmap.strictlyTypedInput` feature gate that introduces stricter
type checks when resolving configuration
- Make `confmap.NewRetrievedFromYAML` function public so that external
providers have consistent behavior when resolving YAML
- Adds `confmap.Retrieved.AsString` method to retrieve string
representation for retrieved values
#### Link to tracking issue
Relates to #9854, updates #8565, #9532
#### Description
This PR adds support for expanding `${}` syntax when no schema is
provided by allowing Resolver to use a default provider.
In a followup PR I'll update otelcol with a feature gate that allow
switching between a default envProvider and the expandconverter.
#### Link to tracking issue
Related to
https://github.com/open-telemetry/opentelemetry-collector/issues/10161
Related to
https://github.com/open-telemetry/opentelemetry-collector/issues/7111
#### Testing
Added unit tests
#### Documentation
Added godoc strings
---------
Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
* [chore] use license shortform
To remain consistent w/ contrib repo, see https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/22052
Signed-off-by: Alex Boten <aboten@lightstep.com>
* make goporto
Signed-off-by: Alex Boten <aboten@lightstep.com>
---------
Signed-off-by: Alex Boten <aboten@lightstep.com>
* confmap: Add support for nested URIs
Addresses #7117.
This PR adds support for nesting URIs, e.g.
```
test: "${http://example.com/?os=${env:OS}}"
```
**Breaking change:**
In the case of an InvalidScheme, error `invalid uri: "g_c_s:VALUE"` will be thrown. Previously, no error was thrown (see [test case](https://github.com/open-telemetry/opentelemetry-collector/blob/v0.74.0/confmap/resolver_test.go#L623-L625)).
Other than the above, there will be no breaking changes. Although the parser now provides the ability to understand why parsing a URI fails (e.g. missing opening `${`), no errors will be thrown to preserve the previous behaviour.
The old way to expand env vars (e.g. `${HOST}`) is not supported in nested URIs, as expanding the old way is done in a converter. This has been documented.
* add issue # to changelog
* address feedback
* address feedback
* address feedback
* Address feedback: change expandStringURI & preserve comment
* Address feedback: move recursion to findURI
* Address feedback: avoid duplicate calls to findURI
* Update confmap/expand.go
Co-authored-by: Bogdan Drutu <lazy@splunk.com>
* Address Feedback
* remove unused errURILimit
* update findURI documentation
* fix test
* Update confmap/expand.go
* Address feedback: remove named return values
---------
Co-authored-by: Bogdan Drutu <lazy@splunk.com>