Skip to content

Yaml - Add value to existing list #2834

@yeikel

Description

@yeikel

It is unclear to me if MergeYaml can do this. I tried a couple of combinations and they did not work for me

Input :

@Test
    void testMerging() {
        rewriteRun(
          spec -> spec
            .expectedCyclesThatMakeChanges(2)
            .recipe(new MergeYaml(
              "$.testing",
              """
                  table:
                    - name: jdk_version
                      value: [ 18 ]
                """,
              true,
              null,
              "name"
            )),
          yaml(
            """
                  testing:
                    table:
                      - name: jdk_version
                        value: [ 17 ]
              """,
            """
                  testing:
                    table:
                      - name: jdk_version
                        value: [17,18]
              """
          )
        );
    }

Related : openrewrite/rewrite-github-actions#40

Metadata

Metadata

Assignees

No one assigned

    Labels

    recipeRequested Recipe

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions