Merge YAML snippet
Recipe ID
org.openrewrite.yaml.MergeYamlArtifact
org.openrewrite:rewrite-yamlMerge a YAML snippet with an existing YAML document.
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.yaml.MergeYaml --recipe-option "key=$.metadata" --recipe-option "yaml=labels:
label-one: "value-one""If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite:rewrite-yaml:8.88.0Options
| Name | Type | Description |
|---|---|---|
keyrequired | String | A JsonPath expression used to find matching keys. e.g. $.metadata |
yamlrequired | String | The YAML snippet to insert. The snippet will be indented to match the style of its surroundings. e.g. labels:
label-one: "value-one" |
acceptTheirs | Boolean | 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. |
objectIdentifyingProperty | String | 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. e.g. name |
filePattern | String | A glob expression representing a file path to search for (relative to the project root). Blank/null matches all. e.g. .github/workflows/*.yml |
insertMode | InsertMode | Choose an insertion point when multiple mappings exist. Default is Last. |
insertProperty | String | Define the key for the insertion mode. Takes the key JsonPath into account. Only useful when insert mode is either Before or After.e.g. some-key |
createNewKeys | Boolean | When the key path does _not_ match any keys, create new keys on the spot. Default is true. |
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats