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

MergedYamlMapping wipes out comments #572

Open
robross0606 opened this issue Jul 21, 2023 · 4 comments
Open

MergedYamlMapping wipes out comments #572

robross0606 opened this issue Jul 21, 2023 · 4 comments

Comments

@robross0606
Copy link

robross0606 commented Jul 21, 2023

When I use MergedYamlMapping with overrideConflicts, the resulting YAML file loses all comments from the original YAML on merge. Without producing an entire example:

final YamlMapping updatedYaml = new MergedYamlMapping(oldYaml, newYaml, true);
System.out.println("OLD------------");
System.out.println(oldYaml.toString());
System.out.println("NEW------------");
System.out.println(newYaml.toString());
System.out.println("UPDATED--------");
System.out.println(updatedYaml.toString());
System.out.println("---------------");

Produces:

[INFO] OLD------------
[INFO] apiVersion: v2
name: Helm Chart Template
description: A Helm chart for Kubernetes
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: 0.0.0
[INFO] NEW------------
[INFO] name: Mock Java Back End Service
description: A mock Java (Quarkus) back end service project used as a sandbox for testing CI processes.
version: "0.0.2-SNAPSHOT"
appVersion: "0.0.2-SNAPSHOT"
[INFO] UPDATED--------
[INFO] apiVersion: v2
name: Mock Java Back End Service
description: A mock Java (Quarkus) back end service project used as a sandbox for testing CI processes.
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
version: "0.0.2-SNAPSHOT"
appVersion: "0.0.2-SNAPSHOT"
[INFO] ---------------

Note how the original has comments while the updated does not. The second you enable overrideConflicts, all comments are lost in the resulting merge on any item that is overridden.

@zoeself
Copy link
Collaborator

zoeself commented Jul 21, 2023

@robross0606 thank you for reporting this. I'll assign someone to take care of it soon.

@robross0606
Copy link
Author

robross0606 commented Jul 21, 2023

Also, is there any way to preserve blank newline spacing when reading or writing the files? The original file has extra newlines between fields, but these appear to be lost on ingestion.

@zoeself
Copy link
Collaborator

zoeself commented Jul 21, 2023

@amihaiemil I couldn't find any assignee for this task. This is either because there are no contributors with role DEV available or because the project does not have enough funds.

Please, make sure there is at least one available contributor with the required role and the project can afford to pay them.

@amihaiemil
Copy link
Member

amihaiemil commented Jul 25, 2023

No, the library does not preserve empty lines as they are not semantically relevant.

We'll look into the comments issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants