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 cmd/limactl/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (

"github.com/lima-vm/lima/v2/cmd/limactl/editflags"
"github.com/lima-vm/lima/v2/pkg/instance"
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
"github.com/lima-vm/lima/v2/pkg/limayaml"
networks "github.com/lima-vm/lima/v2/pkg/networks/reconcile"
"github.com/lima-vm/lima/v2/pkg/store"
"github.com/lima-vm/lima/v2/pkg/store/filenames"
"github.com/lima-vm/lima/v2/pkg/yqutil"
)

Expand Down
5 changes: 3 additions & 2 deletions cmd/limactl/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/spf13/cobra"

"github.com/lima-vm/lima/v2/pkg/ioutilx"
"github.com/lima-vm/lima/v2/pkg/limatype"
"github.com/lima-vm/lima/v2/pkg/sshutil"
"github.com/lima-vm/lima/v2/pkg/store"
)
Expand Down Expand Up @@ -63,7 +64,7 @@ func copyAction(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
instances := make(map[string]*store.Instance)
instances := make(map[string]*limatype.Instance)
scpFlags := []string{}
scpArgs := []string{}
debug, err := cmd.Flags().GetBool("debug")
Expand Down Expand Up @@ -114,7 +115,7 @@ func copyAction(cmd *cobra.Command, args []string) error {
}
return err
}
if inst.Status == store.StatusStopped {
if inst.Status == limatype.StatusStopped {
return fmt.Errorf("instance %q is stopped, run `limactl start %s` to start the instance", instName, instName)
}
if legacySSH {
Expand Down
9 changes: 5 additions & 4 deletions cmd/limactl/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
"github.com/spf13/cobra"

"github.com/lima-vm/lima/v2/pkg/imgutil/proxyimgutil"
"github.com/lima-vm/lima/v2/pkg/limatype"
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
"github.com/lima-vm/lima/v2/pkg/store"
"github.com/lima-vm/lima/v2/pkg/store/filenames"
)

func newDiskCommand() *cobra.Command {
Expand Down Expand Up @@ -243,7 +244,7 @@ func diskDeleteAction(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
var instances []*store.Instance
var instances []*limatype.Instance
for _, instName := range instNames {
inst, err := store.Inspect(ctx, instName)
if err != nil {
Expand Down Expand Up @@ -344,7 +345,7 @@ func diskUnlockAction(cmd *cobra.Command, args []string) error {
diskName, disk.Instance, inst.Errors)
continue
}
if inst.Status == store.StatusRunning {
if inst.Status == limatype.StatusRunning {
logrus.Warnf("Cannot unlock disk %q used by running instance %q", diskName, disk.Instance)
continue
}
Expand Down Expand Up @@ -402,7 +403,7 @@ func diskResizeAction(cmd *cobra.Command, args []string) error {
if disk.Instance != "" {
inst, err := store.Inspect(ctx, disk.Instance)
if err == nil {
if inst.Status == store.StatusRunning {
if inst.Status == limatype.StatusRunning {
return fmt.Errorf("cannot resize disk %q used by running instance %q. Please stop the VM instance", diskName, disk.Instance)
}
}
Expand Down
10 changes: 6 additions & 4 deletions cmd/limactl/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ import (
"github.com/lima-vm/lima/v2/cmd/limactl/editflags"
"github.com/lima-vm/lima/v2/pkg/editutil"
"github.com/lima-vm/lima/v2/pkg/instance"
"github.com/lima-vm/lima/v2/pkg/limatype"
"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
"github.com/lima-vm/lima/v2/pkg/limayaml"
networks "github.com/lima-vm/lima/v2/pkg/networks/reconcile"
"github.com/lima-vm/lima/v2/pkg/store"
"github.com/lima-vm/lima/v2/pkg/store/filenames"
"github.com/lima-vm/lima/v2/pkg/uiutil"
"github.com/lima-vm/lima/v2/pkg/yqutil"
)
Expand All @@ -46,20 +48,20 @@ func editAction(cmd *cobra.Command, args []string) error {

var filePath string
var err error
var inst *store.Instance
var inst *limatype.Instance

if arg == "" {
arg = DefaultInstanceName
}
if err := store.ValidateInstName(arg); err == nil {
if err := dirnames.ValidateInstName(arg); err == nil {
inst, err = store.Inspect(ctx, arg)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("instance %q not found", arg)
}
return err
}
if inst.Status == store.StatusRunning {
if inst.Status == limatype.StatusRunning {
return errors.New("cannot edit a running instance")
}
filePath = filepath.Join(inst.Dir, filenames.LimaYAML)
Expand Down
2 changes: 1 addition & 1 deletion cmd/limactl/factory-reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

"github.com/lima-vm/lima/v2/pkg/cidata"
"github.com/lima-vm/lima/v2/pkg/instance"
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
"github.com/lima-vm/lima/v2/pkg/store"
"github.com/lima-vm/lima/v2/pkg/store/filenames"
)

func newFactoryResetCommand() *cobra.Command {
Expand Down
12 changes: 6 additions & 6 deletions cmd/limactl/genschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
orderedmap "github.com/wk8/go-ordered-map/v2"

"github.com/lima-vm/lima/v2/pkg/jsonschemautil"
"github.com/lima-vm/lima/v2/pkg/limayaml"
"github.com/lima-vm/lima/v2/pkg/limatype"
)

func newGenSchemaCommand() *cobra.Command {
Expand Down Expand Up @@ -52,7 +52,7 @@ func genschemaAction(cmd *cobra.Command, args []string) error {
return err
}

schema := jsonschema.Reflect(&limayaml.LimaYAML{})
schema := jsonschema.Reflect(&limatype.LimaYAML{})
// allow Disk to be either string (name) or object (struct)
schema.Definitions["Disk"].Type = "" // was: "object"
schema.Definitions["Disk"].OneOf = []*jsonschema.Schema{
Expand All @@ -72,10 +72,10 @@ func genschemaAction(cmd *cobra.Command, args []string) error {
{Type: "object"},
}
properties := schema.Definitions["LimaYAML"].Properties
getProp(properties, "os").Enum = toAny(limayaml.OSTypes)
getProp(properties, "arch").Enum = toAny(limayaml.ArchTypes)
getProp(properties, "mountType").Enum = toAny(limayaml.MountTypes)
getProp(properties, "vmType").Enum = toAny(limayaml.VMTypes)
getProp(properties, "os").Enum = toAny(limatype.OSTypes)
getProp(properties, "arch").Enum = toAny(limatype.ArchTypes)
getProp(properties, "mountType").Enum = toAny(limatype.MountTypes)
getProp(properties, "vmType").Enum = toAny(limatype.VMTypes)
j, err := json.MarshalIndent(schema, "", " ")
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion cmd/limactl/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/lima-vm/lima/v2/pkg/limatype"
"github.com/lima-vm/lima/v2/pkg/store"
)

Expand Down Expand Up @@ -172,7 +173,7 @@ func listAction(cmd *cobra.Command, args []string) error {
}

// get the state and config for all the requested instances
var instances []*store.Instance
var instances []*limatype.Instance
for _, instanceName := range instanceNames {
instance, err := store.Inspect(ctx, instanceName)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/limactl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/lima-vm/lima/v2/pkg/debugutil"
"github.com/lima-vm/lima/v2/pkg/driver/external/server"
"github.com/lima-vm/lima/v2/pkg/fsutil"
"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
"github.com/lima-vm/lima/v2/pkg/osutil"
"github.com/lima-vm/lima/v2/pkg/store/dirnames"
"github.com/lima-vm/lima/v2/pkg/version"
)

Expand Down
9 changes: 5 additions & 4 deletions cmd/limactl/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/spf13/cobra"

"github.com/lima-vm/lima/v2/pkg/downloader"
"github.com/lima-vm/lima/v2/pkg/limatype"
"github.com/lima-vm/lima/v2/pkg/limayaml"
"github.com/lima-vm/lima/v2/pkg/store"
"github.com/lima-vm/lima/v2/pkg/templatestore"
Expand Down Expand Up @@ -64,8 +65,8 @@ func pruneAction(cmd *cobra.Command, _ []string) error {
return nil
}

func knownLocations(ctx context.Context) (map[string]limayaml.File, error) {
locations := make(map[string]limayaml.File)
func knownLocations(ctx context.Context) (map[string]limatype.File, error) {
locations := make(map[string]limatype.File)

// Collect locations from instances
instances, err := store.Instances()
Expand Down Expand Up @@ -99,8 +100,8 @@ func knownLocations(ctx context.Context) (map[string]limayaml.File, error) {
return locations, nil
}

func locationsFromLimaYAML(y *limayaml.LimaYAML) map[string]limayaml.File {
locations := make(map[string]limayaml.File)
func locationsFromLimaYAML(y *limatype.LimaYAML) map[string]limatype.File {
locations := make(map[string]limatype.File)
for _, f := range y.Images {
locations[downloader.CacheKey(f.Location)] = f.File
if f.Kernel != nil {
Expand Down
10 changes: 5 additions & 5 deletions cmd/limactl/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/lima-vm/lima/v2/pkg/envutil"
"github.com/lima-vm/lima/v2/pkg/instance"
"github.com/lima-vm/lima/v2/pkg/ioutilx"
"github.com/lima-vm/lima/v2/pkg/limayaml"
"github.com/lima-vm/lima/v2/pkg/limatype"
networks "github.com/lima-vm/lima/v2/pkg/networks/reconcile"
"github.com/lima-vm/lima/v2/pkg/sshutil"
"github.com/lima-vm/lima/v2/pkg/store"
Expand Down Expand Up @@ -86,7 +86,7 @@ func shellAction(cmd *cobra.Command, args []string) error {
}
return err
}
if inst.Status == store.StatusStopped {
if inst.Status == limatype.StatusStopped {
startNow, err := askWhetherToStart()
if err != nil {
return err
Expand Down Expand Up @@ -142,7 +142,7 @@ func shellAction(cmd *cobra.Command, args []string) error {
if workDir != "" {
changeDirCmd = fmt.Sprintf("cd %s || exit 1", shellescape.Quote(workDir))
// FIXME: check whether y.Mounts contains the home, not just len > 0
} else if len(inst.Config.Mounts) > 0 || inst.VMType == limayaml.WSL2 {
} else if len(inst.Config.Mounts) > 0 || inst.VMType == limatype.WSL2 {
hostCurrentDir, err := os.Getwd()
if err == nil && runtime.GOOS == "windows" {
hostCurrentDir, err = mountDirFromWindowsDir(ctx, inst, hostCurrentDir)
Expand Down Expand Up @@ -265,8 +265,8 @@ func shellAction(cmd *cobra.Command, args []string) error {
return sshCmd.Run()
}

func mountDirFromWindowsDir(ctx context.Context, inst *store.Instance, dir string) (string, error) {
if inst.VMType == limayaml.WSL2 {
func mountDirFromWindowsDir(ctx context.Context, inst *limatype.Instance, dir string) (string, error) {
if inst.VMType == limatype.WSL2 {
distroName := "lima-" + inst.Name
return ioutilx.WindowsSubsystemPathForLinux(ctx, dir, distroName)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/limactl/show-ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
"github.com/lima-vm/lima/v2/pkg/sshutil"
"github.com/lima-vm/lima/v2/pkg/store"
"github.com/lima-vm/lima/v2/pkg/store/dirnames"
"github.com/lima-vm/lima/v2/pkg/store/filenames"
)

const showSSHExample = `
Expand Down
20 changes: 11 additions & 9 deletions cmd/limactl/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"github.com/lima-vm/lima/v2/pkg/editutil"
"github.com/lima-vm/lima/v2/pkg/instance"
"github.com/lima-vm/lima/v2/pkg/limatmpl"
"github.com/lima-vm/lima/v2/pkg/limatype"
"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
"github.com/lima-vm/lima/v2/pkg/limayaml"
networks "github.com/lima-vm/lima/v2/pkg/networks/reconcile"
"github.com/lima-vm/lima/v2/pkg/registry"
"github.com/lima-vm/lima/v2/pkg/store"
"github.com/lima-vm/lima/v2/pkg/store/filenames"
"github.com/lima-vm/lima/v2/pkg/templatestore"
"github.com/lima-vm/lima/v2/pkg/uiutil"
"github.com/lima-vm/lima/v2/pkg/yqutil"
Expand Down Expand Up @@ -203,7 +205,7 @@ func printGlobalFlags(cmd *cobra.Command) {
}
}

func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*store.Instance, error) {
func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*limatype.Instance, error) {
ctx := cmd.Context()
var arg string // can be empty
if len(args) > 0 {
Expand All @@ -223,7 +225,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
return nil, err
}
if name != "" {
err := store.ValidateInstName(name)
err := dirnames.ValidateInstName(name)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -258,7 +260,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
tty = false
}
var tmpl *limatmpl.Template
if err := store.ValidateInstName(arg); arg == "" || err == nil {
if err := dirnames.ValidateInstName(arg); arg == "" || err == nil {
tmpl = &limatmpl.Template{Name: name}
if arg == "" {
if name == "" {
Expand Down Expand Up @@ -313,7 +315,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
if _, err := store.Inspect(ctx, tmpl.Name); err == nil {
return nil, fmt.Errorf("instance %q already exists", tmpl.Name)
}
} else if err := store.ValidateInstName(tmpl.Name); err != nil {
} else if err := dirnames.ValidateInstName(tmpl.Name); err != nil {
return nil, err
}
}
Expand Down Expand Up @@ -342,7 +344,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
return instance.Create(cmd.Context(), tmpl.Name, tmpl.Bytes, saveBrokenYAML)
}

func applyYQExpressionToExistingInstance(ctx context.Context, inst *store.Instance, yq string) (*store.Instance, error) {
func applyYQExpressionToExistingInstance(ctx context.Context, inst *limatype.Instance, yq string) (*limatype.Instance, error) {
if strings.TrimSpace(yq) == "" {
return inst, nil
}
Expand Down Expand Up @@ -563,15 +565,15 @@ func startAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("errors inspecting instance: %+v", inst.Errors)
}
switch inst.Status {
case store.StatusRunning:
case limatype.StatusRunning:
logrus.Infof("The instance %q is already running. Run `%s` to open the shell.",
inst.Name, instance.LimactlShellCmd(inst.Name))
// Not an error
return nil
case store.StatusStopped:
case limatype.StatusStopped:
// NOP
default:
logrus.Warnf("expected status %q, got %q", store.StatusStopped, inst.Status)
logrus.Warnf("expected status %q, got %q", limatype.StatusStopped, inst.Status)
}
ctx := cmd.Context()
err = networks.Reconcile(ctx, inst.Name)
Expand Down
2 changes: 1 addition & 1 deletion cmd/limactl/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/spf13/cobra"

"github.com/lima-vm/lima/v2/pkg/limatmpl"
"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
"github.com/lima-vm/lima/v2/pkg/limayaml"
"github.com/lima-vm/lima/v2/pkg/store/dirnames"
"github.com/lima-vm/lima/v2/pkg/yqutil"
)

Expand Down
3 changes: 2 additions & 1 deletion cmd/limactl/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/spf13/cobra"

"github.com/lima-vm/lima/v2/pkg/freeport"
"github.com/lima-vm/lima/v2/pkg/limatype"
"github.com/lima-vm/lima/v2/pkg/sshutil"
"github.com/lima-vm/lima/v2/pkg/store"
)
Expand Down Expand Up @@ -72,7 +73,7 @@ func tunnelAction(cmd *cobra.Command, args []string) error {
}
return err
}
if inst.Status == store.StatusStopped {
if inst.Status == limatype.StatusStopped {
return fmt.Errorf("instance %q is stopped, run `limactl start %s` to start the instance", instName, instName)
}

Expand Down
Loading