2023-08-30 12:39:38 +01:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"log/slog"
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var buildCmd = &cobra.Command{
|
|
|
|
|
Use: "build",
|
|
|
|
|
Short: "Build (set up) a VM image for local use. This needs to be run after the initial installation.",
|
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2023-08-31 20:10:26 +01:00
|
|
|
store := createStoreOrExit()
|
2023-08-30 12:39:38 +01:00
|
|
|
|
|
|
|
|
err := store.BuildVMImageWithInterruptHandler(vmDebugFlag, buildOverwriteFlag)
|
|
|
|
|
if err != nil {
|
|
|
|
|
slog.Error("Failed to build VM image", "error", err.Error())
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
slog.Info("VM image built successfully", "path", store.GetVMImagePath())
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var buildOverwriteFlag bool
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
buildCmd.Flags().BoolVar(&buildOverwriteFlag, "overwrite", false, "Specifies whether the VM image should be overwritten with the build.")
|
|
|
|
|
}
|