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

@@ -5,11 +5,10 @@ import (
"path"
"strconv"
"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"
)
@@ -19,13 +18,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var gid int
var err error
overlayKind := args[0]
overlayName := args[1]
fileName := args[2]
if overlayKind != "system" && overlayKind != "runtime" {
return errors.New("overlay kind must be of type 'system' or 'runtime'")
}
overlayName := args[0]
fileName := args[1]
uid, err = strconv.Atoi(args[3])
if err != nil {
@@ -43,11 +37,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
gid = 0
}
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

@@ -4,12 +4,12 @@ import "github.com/spf13/cobra"
var (
baseCmd = &cobra.Command{
Use: "chown [OPTIONS] {system|runtime} OVERLAY_NAME FILE UID [GID]",
Short: "Change file ownership within an overlay",
Long: "This command changes the ownership of a FILE within the system or runtime OVERLAY_NAME\n" +
"to the user specified by UID. Optionally, it will also change group ownership to GID.",
RunE: CobraRunE,
Args: cobra.RangeArgs(4, 5),
DisableFlagsInUseLine: true,
Use: "chown [OPTIONS] OVERLAY_NAME FILE UID [GID]",
Short: "Change file ownership within an overlay",
Long: "This command changes the ownership of a FILE within the system or runtime OVERLAY_NAME\nto the user specified by UID. Optionally, it will also change group ownership to GID.",
RunE: CobraRunE,
Args: cobra.RangeArgs(3, 4),
}
)