run with copy of workingdir

This commit is contained in:
Casey Lee
2020-02-24 17:48:21 -08:00
parent 8f5918942d
commit 1121f6e132
7 changed files with 26 additions and 9 deletions

View File

@@ -101,6 +101,7 @@ func (cr *containerReference) Copy(destPath string, files ...*FileEntry) common.
func (cr *containerReference) CopyDir(destPath string, srcPath string) common.Executor {
return common.NewPipelineExecutor(
common.NewInfoExecutor("%sdocker cp src=%s dst=%s", logPrefix, srcPath, destPath),
cr.connect(),
cr.find(),
cr.copyDir(destPath, srcPath),
@@ -310,13 +311,14 @@ func (cr *containerReference) copyDir(dstPath string, srcPath string) common.Exe
}
log.Debugf("Writing tarball %s from %s", tarFile.Name(), srcPath)
defer tarFile.Close()
//defer os.Remove(tarFile.Name())
defer os.Remove(tarFile.Name())
tw := tar.NewWriter(tarFile)
srcPrefix := filepath.Dir(srcPath)
if !strings.HasSuffix(srcPrefix, string(filepath.Separator)) {
srcPrefix += string(filepath.Separator)
}
log.Debugf("Stripping prefix:%s src:%s", srcPrefix, srcPath)
err = filepath.Walk(srcPath, func(file string, fi os.FileInfo, err error) error {
if err != nil {
@@ -336,6 +338,7 @@ func (cr *containerReference) copyDir(dstPath string, srcPath string) common.Exe
// update the name to correctly reflect the desired destination when untaring
header.Name = strings.TrimPrefix(file, srcPrefix)
log.Debugf("%s -> %s", file, header.Name)
// write the header
if err := tw.WriteHeader(header); err != nil {