Skip to content

Commit

Permalink
fixing lint errors + adding error checking
Browse files Browse the repository at this point in the history
Signed-off-by: Channing Gaddy <[email protected]>
  • Loading branch information
CodeChanning committed Aug 9, 2023
1 parent 41a1ae5 commit 877eb38
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
7 changes: 5 additions & 2 deletions e2e/vm/soci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ var testSoci = func(o *option.Option, installed bool) {
var limactlO *option.Option
var limaHomePathEnv string
var wd string
var err error

ginkgo.BeforeEach(func() {
wd, _ = os.Getwd()
wd, err = os.Getwd()
gomega.Expect(err).Should(gomega.BeNil())
limaHomePathEnv = "LIMA_HOME=" + filepath.Join(wd, "../../_output/lima/data")
limactlO, _ = option.New([]string{filepath.Join(wd, "../../_output/lima/bin/limactl")},
limactlO, err = option.New([]string{filepath.Join(wd, "../../_output/lima/bin/limactl")},
option.Env([]string{limaHomePathEnv}))
gomega.Expect(err).Should(gomega.BeNil())
})

ginkgo.It("finch pull should have same mounts as nerdctl pull with SOCI", func() {
Expand Down
9 changes: 8 additions & 1 deletion pkg/config/lima_config_applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,14 @@ func (lca *limaConfigApplier) Apply(isInit bool) error {
limaCfg = *cfgAfterInit
}

toggleSoci(&limaCfg, *lca.cfg.Snapshotter == "soci", sociVersion, system.NewStdLib().Arch())
var sociEnabled bool
if lca.cfg.Snapshotter == nil {
sociEnabled = false
} else {
sociEnabled = (*lca.cfg.Snapshotter == "soci")
}

toggleSoci(&limaCfg, sociEnabled, sociVersion, system.NewStdLib().Arch())

limaCfgBytes, err := yaml.Marshal(limaCfg)
if err != nil {
Expand Down
26 changes: 13 additions & 13 deletions pkg/config/lima_config_applier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ fi
}, {
name: "adds soci script when soci is set to true in config",
config: &Finch{
Memory: pointer.String("2GiB"),
CPUs: pointer.Int(4),
VMType: pointer.String("qemu"),
Rosetta: pointer.Bool(false),
Soci: pointer.Bool(true),
Memory: pointer.String("2GiB"),
CPUs: pointer.Int(4),
VMType: pointer.String("qemu"),
Rosetta: pointer.Bool(false),
Snapshotter: pointer.String("soci"),
},
path: "/lima.yaml",
isInit: true,
Expand All @@ -113,9 +113,9 @@ fi
buf, err := afero.ReadFile(fs, "/lima.yaml")
require.NoError(t, err)

fname := fmt.Sprintf(fnameFormat, sociVersion, system.NewStdLib().Arch())
sociDownloadUrl := fmt.Sprintf(sociDownloadUrlFormat, sociVersion, fname)
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat, sociInstallationProvisioningScriptHeader, sociDownloadUrl, fname)
sociFileName := fmt.Sprintf(sociFileNameFormat, sociVersion, system.NewStdLib().Arch())
sociDownloadUrl := fmt.Sprintf(sociDownloadUrlFormat, sociVersion, sociFileName)
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat, sociInstallationProvisioningScriptHeader, sociDownloadUrl, sociFileName)

var limaCfg limayaml.LimaYAML
err = yaml.Unmarshal(buf, &limaCfg)
Expand Down Expand Up @@ -147,11 +147,11 @@ fi
}, {
name: "doesn't add soci script when soci is set to false in config",
config: &Finch{
Memory: pointer.String("2GiB"),
CPUs: pointer.Int(4),
VMType: pointer.String("qemu"),
Rosetta: pointer.Bool(false),
Soci: pointer.Bool(false),
Memory: pointer.String("2GiB"),
CPUs: pointer.Int(4),
VMType: pointer.String("qemu"),
Rosetta: pointer.Bool(false),
Snapshotter: pointer.String("string"),
},
path: "/lima.yaml",
isInit: true,
Expand Down

0 comments on commit 877eb38

Please sign in to comment.