First pass at a rework of the overlay subsystem in Warewulf

This commit is contained in:
Gregory Kurtzer
2021-12-29 16:11:25 -08:00
parent 02a5de3873
commit 00d8d42e9d
62 changed files with 405 additions and 628 deletions

View File

@@ -6,29 +6,19 @@ import (
"os"
"path"
"github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
var overlaySourceDir string
overlayKind := args[0]
overlayName := args[1]
fileName := args[2]
overlayName := args[0]
fileName := args[1]
if overlayKind != "system" && overlayKind != "runtime" {
return errors.New("overlay kind must be of type 'system' or 'runtime'")
}
if overlayKind == "system" {
overlaySourceDir = config.SystemOverlaySource(overlayName)
} else if overlayKind == "runtime" {
overlaySourceDir = config.RuntimeOverlaySource(overlayName)
}
overlaySourceDir = overlay.OverlaySourceDir(overlayName)
if !util.IsDir(overlaySourceDir) {
wwlog.Printf(wwlog.ERROR, "Overlay does not exist: %s\n", overlayName)

View File

@@ -6,12 +6,13 @@ import (
var (
baseCmd = &cobra.Command{
Use: "show [OPTIONS] {system|runtime} OVERLAY_NAME FILE",
Short: "Show (cat) a file within a Warewulf Overlay",
Long: "This command displays the contents of FILE within OVERLAY_NAME.",
RunE: CobraRunE,
Aliases: []string{"cat"},
Args: cobra.ExactArgs(3),
DisableFlagsInUseLine: true,
Use: "show [OPTIONS] OVERLAY_NAME FILE",
Short: "Show (cat) a file within a Warewulf Overlay",
Long: "This command displays the contents of FILE within OVERLAY_NAME.",
RunE: CobraRunE,
Aliases: []string{"cat"},
Args: cobra.ExactArgs(2),
}
)