Skip to content

Commit

Permalink
Remove custom YAML marshaller
Browse files Browse the repository at this point in the history
We used a custom marshaller to properly marshal "~" and "null".
This has been fixed in goccy/go-yaml#474,
which has been merged in lima-vm#2828.

Dropping the custom marshaller fixes lima-vm#2665.

Signed-off-by: Jan Dubois <[email protected]>
  • Loading branch information
jandubois committed Nov 1, 2024
1 parent 8343c5f commit 5d6e39b
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions pkg/limayaml/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,14 @@ import (
"github.com/sirupsen/logrus"
)

func marshalString(s string) ([]byte, error) {
if s == "null" || s == "~" {
// work around go-yaml bugs
return []byte("\"" + s + "\""), nil
}
return yaml.Marshal(s)
}

const (
documentStart = "---\n"
documentEnd = "...\n"
)

// Marshal the struct as a YAML document, optionally as a stream.
func Marshal(y *LimaYAML, stream bool) ([]byte, error) {
options := []yaml.EncodeOption{yaml.CustomMarshaler[string](marshalString)}
b, err := yaml.MarshalWithOptions(y, options...)
b, err := yaml.Marshal(y)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 5d6e39b

Please sign in to comment.