Cleaned container.Build() return
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user