Fixed the bug with importing container/vnfs from a directory.

This commit is contained in:
Yong Qin
2021-04-07 11:25:57 -07:00
parent 3c6837f922
commit 0346d98d46
4 changed files with 8 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/oci"
"github.com/docker/docker/daemon/graphdriver/copy"
)
func ImportDocker(uri string, name string, sCtx *types.SystemContext) error {
@@ -62,11 +63,11 @@ func ImportDirectory(uri string, name string) error {
return errors.New("Import directory does not exist: " + uri)
}
if !util.IsFile(path.Join(fullPath, "/bin/sh")) {
if !util.IsFile(path.Join(uri, "/bin/sh")) {
return errors.New("Source directory has no /bin/sh: " + uri)
}
err = util.CopyFiles(uri, fullPath)
err = copy.DirCopy(uri, fullPath, copy.Content, true)
if err != nil {
return err
}

View File

@@ -126,7 +126,7 @@ func CopyFiles(source string, dest string) error {
//TODO: func CopyRecursive ...
func IsDir(path string) bool {
wwlog.Printf(wwlog.DEBUG, "Chcking if path exists as a directory: %s\n", path)
wwlog.Printf(wwlog.DEBUG, "Checking if path exists as a directory: %s\n", path)
if path == "" {
return false
@@ -138,7 +138,7 @@ func IsDir(path string) bool {
}
func IsFile(path string) bool {
wwlog.Printf(wwlog.DEBUG, "Chcking if path exists as a file: %s\n", path)
wwlog.Printf(wwlog.DEBUG, "Checking if path exists as a file: %s\n", path)
if path == "" {
return false