Replacement inbetween #5616
Labels
kind/feature
Categorizes issue or PR as related to a new feature.
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
Eschewed features
What would you like to have added?
To replace inbetween to substrings or chars would be very benificial. The replacement by delimiter with an index works pretty good but in some cases it is not enough because the part to replace is between two different chars.
Why is this needed?
If for example I want to replace the major version of
nginx:1.7.9
tonginx:2.7.9
there is no right delimiter for me to use to achieve the task. We have this problem in multiple yaml replacements, where the delimiter replacement is not enough.The following issue tries to achieve something similar: #4555
Another example is we have a URL:
http://loki-backend.$(ENVIRONMENT)-myapp-observability.svc.cluster.local:3100$request_uri;
where we want to replace dynamically the$(ENVIRONMENT)
with sta, pre, pro or other environment abbreviations. For now it is not possible to replace this correctly because it is between the char.
and the char-
Can you accomplish the motivating task without this feature, and if so, how?
For now the example cannot be solved because it is between the char
.
and the char-
What other solutions have you considered?
My suggested solution is to have an additional
enddelimiter
property inreplacement.options
which can specify the second char / substring for replacement purpose. This can be done in source and target to be consistent and would have no affect on the current functionallity and a minimal code changeAnything else we should know?
I have created a branch on my fork with an implemented version, due to being new to golang I'm open for clean code or performance optimization suggestion. I also included two basic tests in the
replacement_test.go
which are calledpartial string replacement with enddelimiter in target - replace
andpartial string replacement with enddelimiter in source - replace
Feature ownership
The text was updated successfully, but these errors were encountered: