Skip to content

Commit

Permalink
fix: Fix to allow users to configure disk size for finch space
Browse files Browse the repository at this point in the history
The following parts have been corrected in accordance with the review.

  - Fix text for ginkgo.It blocks in e2e/vm/additional_disk_test.go
  - Apply golangci-lint
  - Add validation finchDiskSize from finch.yaml

Signed-off-by: Hayato Kiwata <[email protected]>
  • Loading branch information
haytok committed Dec 14, 2023
1 parent 097187a commit 8c1df1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions e2e/vm/additional_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ var testAdditionalDisk = func(o *option.Option, installed bool) {
command.Run(o, "start", containerName)
gomega.Expect(command.StdoutStr(o, "exec", containerName, "cat", "/tmp/test.txt")).
Should(gomega.Equal("foo"))

})

ginkgo.It("finch vm init by the disk size for finch area configured in finchDiskSize of ~/.finch.yaml", func() {
ginkgo.It("should correctly configure disk size as specified in finch.yaml", func() {
resetVM(o, installed)
resetDisks(o, installed)
writeFile(finchConfigFilePath, []byte("cpus: 6\nmemory: 4GiB\nvmType: qemu\nrosetta: false\nfinchDiskSize: 3GB"))
Expand Down
11 changes: 7 additions & 4 deletions pkg/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"io/fs"
"path"

"github.com/docker/go-units"
limaStore "github.com/lima-vm/lima/pkg/store"
"github.com/spf13/afero"

Expand All @@ -24,10 +25,8 @@ const (
diskName = "finch"
)

var (
// the amount of disk size allocated for finch space in the virtual machine.
diskSize = "50G"
)
// the amount of disk size allocated for finch space in the virtual machine.
var diskSize = "50G"

// UserDataDiskManager is used to check the user data disk configuration and create it if needed.
type UserDataDiskManager interface {
Expand Down Expand Up @@ -196,6 +195,10 @@ func (m *userDataDiskManager) convertToRaw(diskPath string) error {

func (m *userDataDiskManager) createLimaDisk() error {
if m.config.FinchDiskSize != nil {
_, err := units.RAMInBytes(*m.config.FinchDiskSize)
if err != nil {
return err
}
diskSize = *m.config.FinchDiskSize
}
cmd := m.lcc.CreateWithoutStdio("disk", "create", diskName, "--size", diskSize, "--format", "raw")
Expand Down

0 comments on commit 8c1df1a

Please sign in to comment.