-
Notifications
You must be signed in to change notification settings - Fork 114
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
Add substitution with options #418
Conversation
Signed-off-by: Sven Rebhan <[email protected]>
Signed-off-by: Sven Rebhan <[email protected]>
65110f6
to
1eee7e9
Compare
as there's no issue associated with this PR, can you please clarify how you expect this to be used ? Any upstream project relying on this ? |
@ndeloof we are using this library for Telegraf and have to reproduce a specific behavior namely to only substitute environment-variable expressions if those environment variables are defined. This requirement comes from keeping backward compatibility to not break existing configurations. The issue linked above shows how we use this new function in code. The intension is to be able to better control the replacement process while keeping the nice shell-like interpolation functionality. Please let me know if I should open a corresponding issue! |
For legal reasons we require commits to be signed-off, please amend your commit and force push |
Signed-off-by: Sven Rebhan <[email protected]>
da7daeb
to
e329b70
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add an unit test checking the correct behavior of SubstituteWithOptions
with a replacement function, please?
Signed-off-by: Sven Rebhan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small modification in your test and we're ready to merge the PR
Signed-off-by: Sven Rebhan <[email protected]> Co-authored-by: Guillaume Lours <[email protected]>
0ba2e87
to
e95c1cf
Compare
This PR introduces the
SubstituteWithOptions()
function including options for custom patterns, custom substitution functions and a new replacement function for allowing to customize the replacement behavior if e.g. no mapping was found.The existing
SubstituteWith
function is switched over to the newly introduced function.