Last bit of updates for basic overlay support

This commit is contained in:
Gregory Kurtzer
2020-11-18 20:37:18 -08:00
parent 27441f77d3
commit 0bc53ea483
6 changed files with 145 additions and 3 deletions

View File

@@ -1,6 +1,8 @@
package util
import (
"crypto/sha256"
"fmt"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"io"
"math/rand"
@@ -160,4 +162,23 @@ func ExecInteractive(command string, a...string) error {
c.Stderr = os.Stderr
err := c.Run()
return err
}
func ShaSumFile(file string) (string, error) {
var ret string
f, err := os.Open(file)
if err != nil {
return ret, nil
}
defer f.Close()
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
return ret, err
}
return fmt.Sprintf("%x", h.Sum(nil)), nil
}