Files
warewulf/internal/app/wwctl/overlay/mkdir/main.go
Jonathon Anderson 0b3e862bea Remove trailing newline from wwlog
I noticed that some wwlog calls included a trailing newline, but others
did not. I tested both in isolation and discovered that the behavior was
consistent regardless of whether a trailing newline was included. I
further confirmed in code that wwlog appends a trailing newline
automatically if it is not present; so a trailing newline is unnecessary
in individual calls.

This commit removes trailing newlines from all calls to make them
consistent. It also replaces two calls to wwlog.Printf. (see #534)

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2022-09-15 12:38:03 -06:00

38 lines
820 B
Go

package mkdir
import (
"os"
"path"
"github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
var overlaySourceDir string
overlayName := args[0]
dirName := args[1]
overlaySourceDir = overlay.OverlaySourceDir(overlayName)
if !util.IsDir(overlaySourceDir) {
wwlog.Error("Overlay does not exist: %s", overlayName)
os.Exit(1)
}
overlayDir := path.Join(overlaySourceDir, dirName)
wwlog.Debug("Will create directory in overlay: %s:%s", overlayName, dirName)
err := os.MkdirAll(overlayDir, os.FileMode(PermMode))
if err != nil {
wwlog.Error("Could not create directory: %s", path.Dir(overlayDir))
os.Exit(1)
}
return nil
}