Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MergeYaml edge case: keeps comment at the end of the doc after appending an entry #5135

Open
BoykoAlex opened this issue Mar 5, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@BoykoAlex
Copy link
Contributor

See the test below:

    @Test
    void insertInSequenceEntriesWithDeepSearchWithComment_1() {
        rewriteRun(
          spec -> spec.recipe(new MergeYaml(
            "$..containers",
            "imagePullPolicy: Always",
            true,
            null,
            null,
            null,
            null
          )),
          yaml(
            """
              kind: Pod
              spec:
                containers:
                  - name: <container name>  # comment
              """,
            """
              kind: Pod
              spec:
                containers:
                  - name: <container name>  # comment
                    imagePullPolicy: Always
              """
          )
        );
    }

This fails because # comment is in DocumentEnd node rather than the yaml block. Not sure what to propose... I'd probably try to keep the inline comment as part of the entry... Or perhaps have a special case for the comment at the end of the document if this would be a less intrusive fix.

@BoykoAlex BoykoAlex added the bug Something isn't working label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant