Skip to content

otelconf: add env var substitution in ParseYAML #6215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

codeboten
Copy link
Contributor

This replaces the last bit of functionality that was opened in #4826 to support env variable replacement. Pulled the envprovider.go code from https://github.com/open-telemetry/opentelemetry-collector/blob/main/confmap/provider/envprovider/provider.go

Fixes #4373

@codeboten codeboten requested review from pellared and a team as code owners October 7, 2024 22:38
@codeboten codeboten force-pushed the codeboten/env-var-parsing branch from e08dc29 to 7fc2745 Compare November 5, 2024 23:01
@MrAlias MrAlias added the area: file-config Related to file-based configuration label Feb 20, 2025
@MrAlias
Copy link
Contributor

MrAlias commented Feb 20, 2025

Blocked by #6796: #6796 (comment)

This replaces the last bit of functionality that was opened in open-telemetry#4826 to
support env variable replacement. Pulled the envprovider.go code from https://github.com/open-telemetry/opentelemetry-collector/blob/main/confmap/provider/envprovider/provider.go

Signed-off-by: Alex Boten <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
@codeboten codeboten force-pushed the codeboten/env-var-parsing branch from 7fc2745 to 99b0ce3 Compare March 4, 2025 23:18
@codeboten
Copy link
Contributor Author

@MrAlias moved the code to the new package, this is no longer blocked by that. There's other comments to address that I'll get back to this week

Signed-off-by: Alex Boten <[email protected]>
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

Attention: Patch coverage is 90.32258% with 6 lines in your changes missing coverage. Please review.

Project coverage is 75.8%. Comparing base (5ffb7ff) to head (1bc772a).
Report is 445 commits behind head on main.

Files with missing lines Patch % Lines
otelconf/v0.2.0/config.go 40.0% 2 Missing and 1 partial ⚠️
otelconf/v0.3.0/config.go 40.0% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #6215   +/-   ##
=====================================
  Coverage   75.8%   75.8%           
=====================================
  Files        207     208    +1     
  Lines      19494   19554   +60     
=====================================
+ Hits       14783   14837   +54     
- Misses      4275    4279    +4     
- Partials     436     438    +2     
Files with missing lines Coverage Δ
otelconf/internal/provider/envprovider.go 100.0% <100.0%> (ø)
otelconf/v0.2.0/config.go 76.9% <40.0%> (-3.5%) ⬇️
otelconf/v0.3.0/config.go 87.2% <40.0%> (-2.6%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dmathieu
Copy link
Member

dmathieu commented Mar 5, 2025

It is still blocked, until the release is cut. We agreed config and otelconf would remain in sync for this release.

@codeboten
Copy link
Contributor Author

@dmathieu thanks for clarifying, with the next release started I don't suspect this change will be merged by then anyways :)

Copy link

linux-foundation-easycla bot commented Mar 5, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@codeboten
Copy link
Contributor Author

CLA faillures is being investigated linuxfoundation/easycla#4605

@jarias-lfx
Copy link

/easycla

codeboten and others added 2 commits March 7, 2025 07:12
@codeboten
Copy link
Contributor Author

@pellared would love a review from you as you've requested changes which I made

@pellared
Copy link
Member

@pellared would love a review from you as you've requested changes which I made

I will do my best to review this week. Thanks a lot.

@pellared pellared changed the title config: add support for parsing env variables in configuration config: add env var substitution in ParseYAML Mar 26, 2025
}
}

func TestReplaceEnvVars(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a bunch more tests, still need to ensure all the scenarios are covered and passing, but it's underway

Co-authored-by: Robert Pająk <[email protected]>
codeboten and others added 2 commits March 27, 2025 13:19
Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks very good 👍

I would like only this to get resolved as e.g. I want to have tests that ensures that $$ are escaped correctly 😉

@pellared pellared changed the title config: add env var substitution in ParseYAML otelconf: add env var substitution in ParseYAML Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: file-config Related to file-based configuration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

config: Parse model from YAML
5 participants