Skip to content

Commit 371adc8

Browse files
authored
Merge pull request #2505 from rancher-sandbox/refactor-start-instance
Move pkg/start/* → pkg/instance
2 parents e0edc70 + a27fd07 commit 371adc8

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

cmd/limactl/edit.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99

1010
"github.com/lima-vm/lima/cmd/limactl/editflags"
1111
"github.com/lima-vm/lima/pkg/editutil"
12+
"github.com/lima-vm/lima/pkg/instance"
1213
"github.com/lima-vm/lima/pkg/limayaml"
1314
networks "github.com/lima-vm/lima/pkg/networks/reconcile"
14-
"github.com/lima-vm/lima/pkg/start"
1515
"github.com/lima-vm/lima/pkg/store"
1616
"github.com/lima-vm/lima/pkg/store/filenames"
1717
"github.com/lima-vm/lima/pkg/uiutil"
@@ -42,13 +42,13 @@ func editAction(cmd *cobra.Command, args []string) error {
4242
inst, err := store.Inspect(instName)
4343
if err != nil {
4444
if errors.Is(err, os.ErrNotExist) {
45-
return fmt.Errorf("Instance %q not found", instName)
45+
return fmt.Errorf("instance %q not found", instName)
4646
}
4747
return err
4848
}
4949

5050
if inst.Status == store.StatusRunning {
51-
return errors.New("Cannot edit a running instance")
51+
return errors.New("cannot edit a running instance")
5252
}
5353

5454
filePath := filepath.Join(inst.Dir, filenames.LimaYAML)
@@ -123,7 +123,7 @@ func editAction(cmd *cobra.Command, args []string) error {
123123
if err != nil {
124124
return err
125125
}
126-
return start.Start(ctx, inst, false)
126+
return instance.Start(ctx, inst, false)
127127
}
128128

129129
func askWhetherToStart() (bool, error) {

cmd/limactl/start.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/lima-vm/lima/pkg/ioutilx"
1919
"github.com/lima-vm/lima/pkg/limayaml"
2020
networks "github.com/lima-vm/lima/pkg/networks/reconcile"
21-
"github.com/lima-vm/lima/pkg/start"
2221
"github.com/lima-vm/lima/pkg/store"
2322
"github.com/lima-vm/lima/pkg/store/filenames"
2423
"github.com/lima-vm/lima/pkg/templatestore"
@@ -96,7 +95,7 @@ See the examples in 'limactl create --help'.
9695
if runtime.GOOS != "windows" {
9796
startCommand.Flags().Bool("foreground", false, "run the hostagent in the foreground")
9897
}
99-
startCommand.Flags().Duration("timeout", start.DefaultWatchHostAgentEventsTimeout, "duration to wait for the instance to be running before timing out")
98+
startCommand.Flags().Duration("timeout", instance.DefaultWatchHostAgentEventsTimeout, "duration to wait for the instance to be running before timing out")
10099
return startCommand
101100
}
102101

@@ -449,7 +448,7 @@ func createAction(cmd *cobra.Command, args []string) error {
449448
if len(inst.Errors) > 0 {
450449
return fmt.Errorf("errors inspecting instance: %+v", inst.Errors)
451450
}
452-
if _, err = start.Prepare(cmd.Context(), inst); err != nil {
451+
if _, err = instance.Prepare(cmd.Context(), inst); err != nil {
453452
return err
454453
}
455454
logrus.Infof("Run `limactl start %s` to start the instance.", inst.Name)
@@ -472,7 +471,7 @@ func startAction(cmd *cobra.Command, args []string) error {
472471
switch inst.Status {
473472
case store.StatusRunning:
474473
logrus.Infof("The instance %q is already running. Run `%s` to open the shell.",
475-
inst.Name, start.LimactlShellCmd(inst.Name))
474+
inst.Name, instance.LimactlShellCmd(inst.Name))
476475
// Not an error
477476
return nil
478477
case store.StatusStopped:
@@ -499,10 +498,10 @@ func startAction(cmd *cobra.Command, args []string) error {
499498
return err
500499
}
501500
if timeout > 0 {
502-
ctx = start.WithWatchHostAgentTimeout(ctx, timeout)
501+
ctx = instance.WithWatchHostAgentTimeout(ctx, timeout)
503502
}
504503

505-
return start.Start(ctx, inst, launchHostAgentForeground)
504+
return instance.Start(ctx, inst, launchHostAgentForeground)
506505
}
507506

508507
func createBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {

pkg/start/ansible.go renamed to pkg/instance/ansible.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package start
1+
package instance
22

33
import (
44
"context"

pkg/start/ha_cmd_opts_others.go renamed to pkg/instance/ha_cmd_opts_others.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//go:build !windows
22

3-
package start
3+
package instance
44

55
import (
66
"syscall"

pkg/start/ha_cmd_opts_windows.go renamed to pkg/instance/ha_cmd_opts_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package start
1+
package instance
22

33
import (
44
"syscall"

pkg/start/start.go renamed to pkg/instance/start.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package start
1+
package instance
22

33
import (
44
"bufio"

0 commit comments

Comments
 (0)