From 5a07ac2e14a34b5a202d9f55cf8ceade288420bf Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Wed, 24 Feb 2021 21:01:35 -0800 Subject: [PATCH] Cleaned container.Build() return --- internal/app/wwctl/container/build/main.go | 4 ++-- internal/pkg/container/build.go | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/internal/app/wwctl/container/build/main.go b/internal/app/wwctl/container/build/main.go index b0f9e692..3ce09c93 100644 --- a/internal/app/wwctl/container/build/main.go +++ b/internal/app/wwctl/container/build/main.go @@ -30,12 +30,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error { os.Exit(1) } - output, err := container.Build(c, BuildForce) + err := container.Build(c, BuildForce) if err != nil { wwlog.Printf(wwlog.ERROR, "Could not build container %s: %s\n", c, err) os.Exit(1) } else { - fmt.Printf("%-20s: %s\n", c, output) + //fmt.Printf("%-20s: %s\n", c, output) } } diff --git a/internal/pkg/container/build.go b/internal/pkg/container/build.go index 0b4e5256..87c6ae3e 100644 --- a/internal/pkg/container/build.go +++ b/internal/pkg/container/build.go @@ -11,40 +11,41 @@ import ( "github.com/hpcng/warewulf/internal/pkg/wwlog" ) -func Build(name string, buildForce bool) (string, error) { +func Build(name string, buildForce bool) error { rootfsPath := RootFsDir(name) imagePath := ImageFile(name) if ValidSource(name) == false { - return "", errors.New("Container does not exist") + return errors.New("Container does not exist") } if buildForce == false { wwlog.Printf(wwlog.DEBUG, "Checking if there have been any updates to the VNFS directory\n") if util.PathIsNewer(rootfsPath, imagePath) { - return "Skipping (VNFS is current)", nil + + return errors.New("Skipping (VNFS is current)") } } wwlog.Printf(wwlog.DEBUG, "Making parent directory for: %s\n", name) err := os.MkdirAll(path.Dir(imagePath), 0755) if err != nil { - return "Failed creating directory", err + return errors.New("Failed creating directory") } wwlog.Printf(wwlog.DEBUG, "Making parent directory for: %s\n", rootfsPath) err = os.MkdirAll(path.Dir(rootfsPath), 0755) if err != nil { - return "Failed creating directory", err + return errors.New("Failed creating directory") } wwlog.Printf(wwlog.DEBUG, "Building VNFS image: '%s' -> '%s'\n", rootfsPath, imagePath) cmd := fmt.Sprintf("cd %s; find . | cpio --quiet -o -H newc | gzip -c > \"%s\"", rootfsPath, imagePath) err = exec.Command("/bin/sh", "-c", cmd).Run() if err != nil { - return "Failed building VNFS", err + return errors.New("Failed building VNFS") } - return "Done", nil + return nil }