Copy YAML value

Apache 2.0

Copies a YAML value from one key to another. The existing key/value pair remains unaffected by this change. Attempts to merge the copied value into the new key if it already exists. By default, attempts to create the new key if it does not exist.

org.openrewrite.yaml.CopyValue

Required

A JsonPath expression to locate a YAML key/value pair to copy.

A JsonPath expression defining where the value should be written.

Optional

The file path to the YAML file to copy the value from. If null then the value will be copied from any yaml file it appears within.

The file path to the YAML file to copy the value to. If null then the value will be copied only into the same file it was found in.

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.CopyValue \ -P oldKeyPath='$.source.kind' \ -P newKey='$.dest.kind'

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