--- a/workspace/fileio.go Sat Jul 27 11:33:28 2019 -0500
+++ b/workspace/fileio.go Sat Jul 27 13:09:03 2019 -0500
@@ -17,10 +17,12 @@
func (ws *Workspace) TaskDirectory(name string) (string, error) {
@@ -61,10 +63,60 @@
return os.Rename(tmp.Name(), dst)
+func (ws *Workspace) copyDir(src, dst string, perm os.FileMode) error { + err := filepath.Walk(src, func(path string, info os.FileInfo, err error) error { + // make sure we're copying files that are at the same level as convey.yml or + if !strings.HasPrefix(path, ws.parent) { + "attempted to copy %q which is outside of the run context of %q", + // make sure we're don't try to import anything from the .convey directory + if strings.HasPrefix(path, ws.root) { + // at this point we're going to do something so we need to the real + realDst := filepath.Join(ws.volumePath, strings.TrimPrefix(path, ws.parent)) + // if path is a directory, create it + err := os.Mkdir(realDst, 0755) + // this will get called with the root of the volume, so we need to + // handle the error if it exists. + // at this point we have a file so let's copy it + return ws.copyFile(path, realDst, 0644) func (ws *Workspace) Import(src, dst string) error {
realDst := filepath.Join(ws.volumePath, dst)
- return ws.copyFile(src, realDst, 0644)
+ file, err := os.Stat(src) + return ws.copyDir(src, realDst, 0644) + return ws.copyFile(src, realDst, 0644) func (ws *Workspace) Export(src, dst string) error {
--- a/workspace/workspace.go Sat Jul 27 11:33:28 2019 -0500
+++ b/workspace/workspace.go Sat Jul 27 13:09:03 2019 -0500
@@ -24,18 +24,20 @@
-func New(root string) (*Workspace, error) {
- parent := filepath.Join(root, ".convey")
- err := os.MkdirAll(parent, 0700)
+func New(parent string) (*Workspace, error) { + root := filepath.Join(parent, ".convey") + err := os.MkdirAll(root, 0700) - path, err := ioutil.TempDir(parent, "")
+ path, err := ioutil.TempDir(root, "") @@ -47,6 +49,8 @@