-
-
Notifications
You must be signed in to change notification settings - Fork 108
feat(transformers): JsonMatch in Transformers #6863
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
Conversation
|
Thanks for the PR Isnt't the source of kind "json" enough? Have you considered chaining multiple sources with one of the kind "json" instead of using it in the transformers? |
|
@olblak -- I'm not exactly sure what you mean by chaining sources together -- so
The actual data is coming from an HTTP source -- and while I know you can use a URL with the JSON source, the HTTP call itself is a POST with a body (hence my other PR!) and additional auth headers, which can't be done with the simple URL support within the JSON source. I had considered looking at supporting this type of HTTP support within the JSON source (and other file-based sources) but that looked like a much bigger change! I had also considered (and even PoC'ed) a HTTP source -> File Target -> JSON source -> File Target... BUT that is a heck of a lot of steps vs just HTTP source (w/transformer) -> File Target... I also felt that while that PoC was a viable solution (if clunky), it spreads the logic of getting the source data (and cleaning it) into multiple places... unlike simply using transforms within the originating source to output the data exactly as needed by the next steps. To your concern though, I would suggest being able to process JSON data as both a source and as a transformer is actually powerful. Originally I thought it could deprecate the JSON source -- ie use a File source and a JSON transformer BUT I think the way you think about this is that the transformer is for more simple cases, or where (like my case) the source data isn't coming from a file whereas the JSON source is what you use if you need a more powerful solution, ie could support more powerful JSON handling in the future without overly complicating the transformers |
|
Thanks for the detailed explanation.
I agree with your observation, we decided to add a HTTP source because we didn't want to bloat the current file sources used for json, yaml,etc.
When we need to pass information from one source to another one, we use something like: where dependson ensure that source "debian-digest" is executed after "debian" That's how I thought about having a source of kind "HTTP" followed by a source of kind "JSON" But I agree that your proposal about using a json transformer would simplify the manifest |
Support use of json matching as a transformer such as:
{ "ver": "1.17.0" }.ver1.17.0{ "key": "test" }.ver{ "key": "test" }NoMatchResult="<input>"{ "key": "test" }.ver""NoMatchResult="<blank>"{ "key": "test" }.ver{}NoMatchResult="{}"{ "key": "test" }.ver{ "ver": [ "1.17.0", "1.17.1" ] }.ver.all(){ "ver": [ "1.17.0", "1.17.1" ] }.ver.all()1.17.0MultipleValueSelect="first"{ "ver": [ "1.17.0", "1.17.1" ] }.ver.all()1.17.1MultipleValueSelect="last"{ "ver": [ "1.17.0", "1.17.1" ] }.ver.all()1.17.0MultipleValueSelect="[0]"{ "ver": [ "1.17.0", "1.17.1" ] }.ver.all()MultipleValueSelect="[3]"{ "ver": [ "1.17.0", "1.17.1" ] }.ver.all()1.17.1MultipleValueSelect="[-1]"{ "ver": [ "1.17.0", "1.17.1" ] }.ver.all()1.17.0MultipleValueSelect="[-2]"{ "ver": [ "1.17.0", "1.17.1" ] }.ver.all()MultipleValueSelect="[-3]"{ "ver": [ "1.17.0", "1.17.1" ] }.ver.all()MultipleValueSelect="blah"{ "ver": [ "1.17.0", "1.17.1" ] }.ver.all()MultipleValueSelect="[blah]"{ "ver": [ "1.17.0", "1.17.1" ] }.ver.all()1.17.0,1.17.1JoinMultipleMatches=","