Merge YAML snippet

Apache 2.0

Merge a YAML snippet with an existing YAML document.

org.openrewrite.yaml.MergeYaml

Required

A JsonPath expression used to find matching keys.

The YAML snippet to insert. The snippet will be indented to match the style of its surroundings.

Optional

acceptTheirsBoolean

When the YAML snippet to insert conflicts with an existing key value pair and an existing key has a different value, prefer the original value.

Name of a property which will be used to identify objects (mapping). This serves as the key to match on when merging entries of a sequence.

A glob expression representing a file path to search for (relative to the project root). Blank/null matches all.

Choose an insertion point when multiple mappings exist. Default is Last.

Define the key for the insertion mode. Takes the key JsonPath into account. Only useful when insert mode is either Before or After.

createNewKeysBoolean

When the key path does not match any keys, create new keys on the spot. Default is true.

mod run . --recipe=org.openrewrite.yaml.MergeYaml \ -P key='$.metadata' \ -P yaml='labels: label-one: "value-one"'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.