Skip to content

Commit

Permalink
Change mount mountPoint to string pointer
Browse files Browse the repository at this point in the history
Signed-off-by: Anders F Björklund <[email protected]>
  • Loading branch information
afbjorklund committed May 5, 2024
1 parent 9226e29 commit 8bfb214
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mounts:
- location: "~"
# Configure the mountPoint inside the guest.
# 🟢 Builtin default: value of location
mountPoint: ""
mountPoint: null
# CAUTION: `writable` SHOULD be false for the home directory.
# Setting `writable` to true is possible, but untested and dangerous.
# 🟢 Builtin default: false
Expand Down
2 changes: 1 addition & 1 deletion pkg/cidata/cidata.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML, udpDNSLocalPort
if err != nil {
return err
}
mountPoint, err := localpathutil.Expand(f.MountPoint)
mountPoint, err := localpathutil.Expand(*f.MountPoint)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/hostagent/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (a *HostAgent) setupMount(m limayaml.Mount) (*mount, error) {
return nil, err
}

mountPoint, err := localpathutil.Expand(m.MountPoint)
mountPoint, err := localpathutil.Expand(*m.MountPoint)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/limayaml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
if mount.Writable != nil {
mounts[i].Writable = mount.Writable
}
if mount.MountPoint != "" {
if mount.MountPoint != nil {
mounts[i].MountPoint = mount.MountPoint
}
} else {
Expand Down Expand Up @@ -650,8 +650,8 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
mounts[i].NineP.Cache = ptr.Of(Default9pCacheForRO)
}
}
if mount.MountPoint == "" {
mounts[i].MountPoint = mount.Location
if mount.MountPoint == nil {
mounts[i].MountPoint = ptr.Of(mount.Location)
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/limayaml/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func TestFillDefault(t *testing.T) {
}

expect.Mounts = y.Mounts
expect.Mounts[0].MountPoint = expect.Mounts[0].Location
expect.Mounts[0].MountPoint = ptr.Of(expect.Mounts[0].Location)
expect.Mounts[0].Writable = ptr.Of(false)
expect.Mounts[0].SSHFS.Cache = ptr.Of(true)
expect.Mounts[0].SSHFS.FollowSymlinks = ptr.Of(false)
Expand Down Expand Up @@ -395,7 +395,7 @@ func TestFillDefault(t *testing.T) {
expect = d
// Also verify that archive arch is filled in
expect.Containerd.Archives[0].Arch = *d.Arch
expect.Mounts[0].MountPoint = expect.Mounts[0].Location
expect.Mounts[0].MountPoint = ptr.Of(expect.Mounts[0].Location)
expect.Mounts[0].SSHFS.Cache = ptr.Of(true)
expect.Mounts[0].SSHFS.FollowSymlinks = ptr.Of(false)
expect.Mounts[0].SSHFS.SFTPDriver = ptr.Of("")
Expand Down
2 changes: 1 addition & 1 deletion pkg/limayaml/limayaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ type Disk struct {

type Mount struct {
Location string `yaml:"location" json:"location"` // REQUIRED
MountPoint string `yaml:"mountPoint,omitempty" json:"mountPoint,omitempty"`
MountPoint *string `yaml:"mountPoint,omitempty" json:"mountPoint,omitempty" jsonschema:"nullable"`
Writable *bool `yaml:"writable,omitempty" json:"writable,omitempty" jsonschema:"nullable"`
SSHFS SSHFS `yaml:"sshfs,omitempty" json:"sshfs,omitempty"`
NineP NineP `yaml:"9p,omitempty" json:"9p,omitempty"`
Expand Down

0 comments on commit 8bfb214

Please sign in to comment.