First pass at a rework of the overlay subsystem in Warewulf
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user