openrewrite / rewrite

Automated mass refactoring of source code.

Home Page:https://docs.openrewrite.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Merge Yaml to a specific File

Sid532001 opened this issue · comments

Hi @openrewrite i want to write a recipe which inserts a snippet inside a key in a specific yaml file in my case application.yaml

Current scenario

i have a field
animals:

End result

I want my result to look like this
animals:
dog:
pet:
labrador

image

Do we have any recipe to perform this operation on a specific file
@timtebeek

Sure, you can use our merge yaml recipe and combine that with a precondition that limits the recipe to files matching a particular path, as seen here: https://docs.openrewrite.org/reference/yaml-format-reference#preconditions

Hope that helps!