diff --git a/cmd/limactl/restart.go b/cmd/limactl/restart.go index a46bd09e0be..7416b84ecec 100644 --- a/cmd/limactl/restart.go +++ b/cmd/limactl/restart.go @@ -21,6 +21,7 @@ func newRestartCommand() *cobra.Command { } restartCmd.Flags().BoolP("force", "f", false, "Force stop and restart the instance") + restartCmd.Flags().Bool("progress", false, "Show provision script progress by tailing cloud-init logs") return restartCmd } @@ -40,12 +41,16 @@ func restartAction(cmd *cobra.Command, args []string) error { if err != nil { return err } + progress, err := cmd.Flags().GetBool("progress") + if err != nil { + return err + } if force { - return instance.RestartForcibly(ctx, inst) + return instance.RestartForcibly(ctx, inst, progress) } - return instance.Restart(ctx, inst) + return instance.Restart(ctx, inst, progress) } func restartBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { diff --git a/pkg/instance/restart.go b/pkg/instance/restart.go index 310bfd80214..52db7a4d3ee 100644 --- a/pkg/instance/restart.go +++ b/pkg/instance/restart.go @@ -14,10 +14,9 @@ import ( const ( launchHostAgentForeground = false - showProgress = false ) -func Restart(ctx context.Context, inst *limatype.Instance) error { +func Restart(ctx context.Context, inst *limatype.Instance, showProgress bool) error { if err := StopGracefully(ctx, inst, true); err != nil { return err } @@ -33,7 +32,7 @@ func Restart(ctx context.Context, inst *limatype.Instance) error { return nil } -func RestartForcibly(ctx context.Context, inst *limatype.Instance) error { +func RestartForcibly(ctx context.Context, inst *limatype.Instance, showProgress bool) error { logrus.Info("Restarting the instance forcibly") StopForcibly(inst)