spike: Comments in devfile.yaml not preserved when using Devfile library #919
Labels
area/library
Common devfile library for interacting with devfiles
kind/enhancement
New feature or request
lifecycle/rotten
Rotten items. These items have been stale for 60 days and are now closed.
lifecycle/stale
Stale items. These items have not been updated for 90 days.
/kind bug
Which area this bug is related to?
/area library
What versions of software are you using?
Operating System:
Fedora 36
Go Pkg Version:
Bug Summary
Describe the bug:
odo
commands (likeodo add binding
orodo remove binding
commands) that edit thedevfile.yaml
file will save the Devfile without comments preserved.A first investigation on the odo side led me to the Devfile library, which uses sigs.k8s.io/yaml, which in turn relies on JSON as an intermediate format to convert YAML to/from Go structs.
To Reproduce:
See the test cases added in the following repo: https://github.com/rm3l/devfile-lib-comment-preservation-issue.
To reproduce the issue using
odo
, see redhat-developer/odo#5789 (comment) instead.Expected behavior
Comments are preserved. I think this is important as we want the Devfile to be the main source of truth in odo. So users that write ("carefully crafted") comments should have their comments always preserved.
Any logs, error output, screenshots etc? Provide the devfile that sees this bug, if applicable.
Additional context
kubectl
reportedly has a similar issue with commands that edit the kubeconfig file:kubectl config
drops all comments from kubeconfig file kubernetes/kubectl#1262Any workaround?
No workaround so far.
Suggestion on how to fix the bug
go-yaml v3 brought in comment handling, via a new Node representation that allows preserving comments near the data they describe.
So the recommended way to have comments preserved is via this Node representation, but I guess this will not allow consistent handling of both YAML and JSON.
As we discussed during a community call, other tools might need JSON handling as well.
The text was updated successfully, but these errors were encountered: