UI updates to include "overlay kind"

This commit is contained in:
Gregory Kurtzer
2021-09-13 13:28:44 -07:00
parent 5bff8be72e
commit 3137f477bf
21 changed files with 241 additions and 214 deletions

View File

@@ -6,30 +6,33 @@ import (
"github.com/hpcng/warewulf/internal/pkg/node"
"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 {
if len(args) < 1 {
//nolint:errcheck
cmd.Help()
os.Exit(1)
overlayKind := args[0]
overlayName := args[1]
if overlayKind != "system" && overlayKind != "runtime" {
return errors.New("overlay kind must be of type 'system' or 'runtime'")
}
if SystemOverlay {
err := overlay.SystemOverlayInit(args[0])
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", args[0])
wwlog.Printf(wwlog.INFO, "Created new system overlay: %s\n", overlayName)
} else {
err := overlay.RuntimeOverlayInit(args[0])
err := overlay.RuntimeOverlayInit(overlayName)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
wwlog.Printf(wwlog.INFO, "Created new runtime overlay: %s\n", args[0])
wwlog.Printf(wwlog.INFO, "Created new runtime overlay: %s\n", overlayName)
}
if !NoOverlayUpdate {
@@ -48,17 +51,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay && node.SystemOverlay.Get() == args[0] {
if overlayKind == "system" && node.SystemOverlay.Get() == overlayName {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.Get() == args[0] {
} else if overlayKind == "runtime" && node.RuntimeOverlay.Get() == overlayName {
updateNodes = append(updateNodes, node)
}
}
if SystemOverlay {
if overlayKind == "system" {
wwlog.Printf(wwlog.INFO, "Updating System Overlays...\n")
return overlay.BuildSystemOverlay(updateNodes)
} else {
} else if overlayKind == "runtime" {
wwlog.Printf(wwlog.INFO, "Updating Runtime Overlays...\n")
return overlay.BuildRuntimeOverlay(updateNodes)
}