Skip to content

Commit fd80379

Browse files
committed
limactl restart: add --progress
fix #3906 Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
1 parent 6aceec3 commit fd80379

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

cmd/limactl/restart.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func newRestartCommand() *cobra.Command {
2121
}
2222

2323
restartCmd.Flags().BoolP("force", "f", false, "Force stop and restart the instance")
24+
restartCmd.Flags().Bool("progress", false, "Show provision script progress by tailing cloud-init logs")
2425
return restartCmd
2526
}
2627

@@ -40,12 +41,16 @@ func restartAction(cmd *cobra.Command, args []string) error {
4041
if err != nil {
4142
return err
4243
}
44+
progress, err := cmd.Flags().GetBool("progress")
45+
if err != nil {
46+
return err
47+
}
4348

4449
if force {
45-
return instance.RestartForcibly(ctx, inst)
50+
return instance.RestartForcibly(ctx, inst, progress)
4651
}
4752

48-
return instance.Restart(ctx, inst)
53+
return instance.Restart(ctx, inst, progress)
4954
}
5055

5156
func restartBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {

pkg/instance/restart.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ import (
1414

1515
const (
1616
launchHostAgentForeground = false
17-
showProgress = false
1817
)
1918

20-
func Restart(ctx context.Context, inst *limatype.Instance) error {
19+
func Restart(ctx context.Context, inst *limatype.Instance, showProgress bool) error {
2120
if err := StopGracefully(ctx, inst, true); err != nil {
2221
return err
2322
}
@@ -33,7 +32,7 @@ func Restart(ctx context.Context, inst *limatype.Instance) error {
3332
return nil
3433
}
3534

36-
func RestartForcibly(ctx context.Context, inst *limatype.Instance) error {
35+
func RestartForcibly(ctx context.Context, inst *limatype.Instance, showProgress bool) error {
3736
logrus.Info("Restarting the instance forcibly")
3837
StopForcibly(inst)
3938

0 commit comments

Comments
 (0)