Files
warewulf/internal/app/wwctl/overlay/create/main.go
2021-09-29 22:06:46 -07:00

38 lines
815 B
Go

package create
import (
"os"
"github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
overlayKind := args[0]
overlayName := args[1]
if overlayKind != "system" && overlayKind != "runtime" {
return errors.New("overlay kind must be of type 'system' or 'runtime'")
}
if overlayKind == "system" {
err := overlay.SystemOverlayInit(overlayName)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
wwlog.Printf(wwlog.INFO, "Created new system overlay: %s\n", overlayName)
} else {
err := overlay.RuntimeOverlayInit(overlayName)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
}
return nil
}