Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ssh:
# 🟢 Builtin default: 0 (automatically assigned to a free port)
# NOTE: when the instance name is "default", the builtin default value is set to
# 60022 for backward compatibility.
localPort: 0
localPort: null
# Load ~/.ssh/*.pub in addition to $LIMA_HOME/_config/user.pub .
# This option is useful when you want to use other SSH-based
# applications such as rsync with the Lima instance.
Expand Down
4 changes: 2 additions & 2 deletions pkg/limayaml/limayaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ const (
)

type Rosetta struct {
Enabled *bool `yaml:"enabled" json:"enabled"`
BinFmt *bool `yaml:"binfmt" json:"binfmt"`
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
BinFmt *bool `yaml:"binfmt,omitempty" json:"binfmt,omitempty"`
}

type File struct {
Expand Down
43 changes: 43 additions & 0 deletions pkg/limayaml/limayaml_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package limayaml

import (
"encoding/json"
"os"
"testing"

"gotest.tools/v3/assert"
)

func dumpJSON(t *testing.T, d interface{}) string {
b, err := json.Marshal(d)
if err != nil {
t.Fatal(err)
}
return string(b)
}

const emptyYAML = "images: []\n"

func TestEmptyYAML(t *testing.T) {
var y LimaYAML
t.Log(dumpJSON(t, y))
b, err := marshalYAML(y)
assert.NilError(t, err)
assert.Equal(t, string(b), emptyYAML)
}

const defaultYAML = "images: []\n"

func TestDefaultYAML(t *testing.T) {
bytes, err := os.ReadFile("default.yaml")
assert.NilError(t, err)
var y LimaYAML
err = unmarshalYAML(bytes, &y, "")
assert.NilError(t, err)
y.Images = nil // remove default images
y.Mounts = nil // remove default mounts
t.Log(dumpJSON(t, y))
b, err := marshalYAML(y)
assert.NilError(t, err)
assert.Equal(t, string(b), defaultYAML)
}