replaced errors.Wrap with fmt.Errorf
Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
c0703c32d4
commit
0dd0317740
@@ -11,7 +11,6 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
|
||||
"github.com/warewulf/warewulf/internal/pkg/container"
|
||||
@@ -39,7 +38,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
conf := warewulfconf.Get()
|
||||
runDir := container.RunDir(containerName)
|
||||
if _, err := os.Stat(runDir); os.IsNotExist(err) {
|
||||
return errors.Wrap(err, "container run directory does not exist")
|
||||
return fmt.Errorf("container run directory does not exist: %w", err)
|
||||
}
|
||||
mountPts := conf.MountsContainer
|
||||
mountPts = append(container.InitMountPnts(binds), mountPts...)
|
||||
@@ -80,7 +79,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
// running in a private PID space, so also make / private, so that nothing gets out from here
|
||||
err = syscall.Mount("", "/", "", syscall.MS_PRIVATE|syscall.MS_REC, "")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to mount")
|
||||
return fmt.Errorf("failed to mount: %w", err)
|
||||
}
|
||||
ps1Str := fmt.Sprintf("[%s|%s] Warewulf> ", containerName, exitEval)
|
||||
wwlog.Info(msgStr)
|
||||
@@ -126,11 +125,11 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
ps1Str = fmt.Sprintf("[%s|ro] Warewulf> ", containerName)
|
||||
err = syscall.Mount(containerPath, containerPath, "", syscall.MS_BIND, "")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to prepare bind mount")
|
||||
return fmt.Errorf("failed to prepare bind mount: %w", err)
|
||||
}
|
||||
err = syscall.Mount(containerPath, containerPath, "", syscall.MS_REMOUNT|syscall.MS_RDONLY|syscall.MS_BIND, "")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to remount ro")
|
||||
return fmt.Errorf("failed to remount ro: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,25 +155,25 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
|
||||
err = syscall.Chroot(containerPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to chroot")
|
||||
return fmt.Errorf("failed to chroot: %w", err)
|
||||
}
|
||||
|
||||
err = os.Chdir("/")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to chdir")
|
||||
return fmt.Errorf("failed to chdir: %w", err)
|
||||
}
|
||||
|
||||
if err := syscall.Mount("devtmpfs", "/dev", "devtmpfs", 0, ""); err != nil {
|
||||
return errors.Wrap(err, "failed to mount /dev")
|
||||
return fmt.Errorf("failed to mount /dev: %w", err)
|
||||
}
|
||||
if err := syscall.Mount("sysfs", "/sys", "sysfs", 0, ""); err != nil {
|
||||
return errors.Wrap(err, "failed to mount /sys")
|
||||
return fmt.Errorf("failed to mount /sys: %w", err)
|
||||
}
|
||||
if err := syscall.Mount("proc", "/proc", "proc", 0, ""); err != nil {
|
||||
return errors.Wrap(err, "failed to mount /proc")
|
||||
return fmt.Errorf("failed to mount /proc: %w", err)
|
||||
}
|
||||
if err := syscall.Mount("tmpfs", "/run", "tmpfs", 0, ""); err != nil {
|
||||
return errors.Wrap(err, "failed to mount /run")
|
||||
return fmt.Errorf("failed to mount /run: %w", err)
|
||||
}
|
||||
|
||||
os.Setenv("PS1", ps1Str)
|
||||
|
||||
@@ -3,7 +3,6 @@ package imprt
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/pkg/container"
|
||||
"github.com/warewulf/warewulf/internal/pkg/kernel"
|
||||
@@ -68,12 +67,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
err = nodeDB.Persist()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to persist nodedb")
|
||||
return fmt.Errorf("failed to persist nodedb: %w", err)
|
||||
}
|
||||
fmt.Printf("Set default kernel version to: %s\n", args[0])
|
||||
err = warewulfd.DaemonReload()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to reload warewulf daemon")
|
||||
return fmt.Errorf("failed to reload warewulf daemon: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
apinode "github.com/warewulf/warewulf/internal/pkg/api/node"
|
||||
"github.com/warewulf/warewulf/internal/pkg/api/routes/wwapiv1"
|
||||
@@ -133,7 +132,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
err = warewulfd.DaemonReload()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to reload warewulf daemon")
|
||||
return fmt.Errorf("failed to reload warewulf daemon: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -39,12 +39,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if Force {
|
||||
err := os.RemoveAll(overlayPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed deleting overlay")
|
||||
return fmt.Errorf("failed deleting overlay: %w", err)
|
||||
}
|
||||
} else {
|
||||
err := os.Remove(overlayPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed deleting overlay")
|
||||
return fmt.Errorf("failed deleting overlay: %w", err)
|
||||
}
|
||||
}
|
||||
wwlog.Info("Deleted overlay: %s\n", args[0])
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/pkg/node"
|
||||
"github.com/warewulf/warewulf/internal/pkg/overlay"
|
||||
@@ -59,7 +58,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
err := util.CopyFile(source, path.Join(overlaySource, dest))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not copy file into overlay")
|
||||
return fmt.Errorf("could not copy file into overlay: %w", err)
|
||||
}
|
||||
|
||||
if !NoOverlayUpdate {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/pkg/overlay"
|
||||
"github.com/warewulf/warewulf/internal/pkg/util"
|
||||
@@ -20,7 +20,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var err error
|
||||
overlays, err = overlay.FindOverlays()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not obtain list of overlays from system")
|
||||
return fmt.Errorf("could not obtain list of overlays from system: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/manifoldco/promptui"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/pkg/node"
|
||||
"github.com/warewulf/warewulf/internal/pkg/util"
|
||||
@@ -39,7 +38,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Verbose("Removing profile from node %s: %s", n.Id(), r)
|
||||
n.Profiles = append(n.Profiles[:i], n.Profiles[i+1:]...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update node")
|
||||
return fmt.Errorf("failed to update node: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,7 +72,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if SetYes {
|
||||
err := nodeDB.Persist()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to persist nodedb")
|
||||
return fmt.Errorf("failed to persist nodedb: %w", err)
|
||||
}
|
||||
} else {
|
||||
prompt := promptui.Prompt{
|
||||
@@ -86,7 +85,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if result == "y" || result == "yes" {
|
||||
err := nodeDB.Persist()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to persist nodedb")
|
||||
return fmt.Errorf("failed to persist nodedb: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/pkg/warewulfd"
|
||||
)
|
||||
@@ -21,7 +22,7 @@ func GetCommand() *cobra.Command {
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if err := warewulfd.DaemonInitLogging(); err != nil {
|
||||
return errors.Wrap(err, "failed to configure logging")
|
||||
return fmt.Errorf("failed to configure logging: %w", err)
|
||||
}
|
||||
return errors.Wrap(warewulfd.RunServer(), "failed to start Warewulf server")
|
||||
return fmt.Errorf("failed to start Warewulf server: %w", warewulfd.RunServer())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user