grim/convey

Fix up the export tasks

2019-07-27, Gary Kramlich
c77346921bec
Parents f51e1d3471eb
Children 04cb9ec74afa
Fix up the export tasks
--- a/tasks/export.go Sat Jul 27 14:15:34 2019 -0500
+++ b/tasks/export.go Sat Jul 27 15:19:35 2019 -0500
@@ -47,10 +47,13 @@
// Executes the task
func (e *Export) Execute(name string, logger *log.Entry, env *environment.Environment, rt *runtime.Runtime) error {
+ fullEnv := env.Copy().Merge(rt.Environment)
+
for _, pattern := range e.Files {
+ pattern = fullEnv.Map(pattern)
src, dst := path.ParseFilePath("", pattern)
- matches, err := filepath.Glob(filepath.Join(rt.State.Workspace.Path(), src))
+ matches, err := filepath.Glob(filepath.Join(rt.State.Workspace.Volume(), src))
if err != nil {
return err
}
@@ -58,7 +61,7 @@
for _, match := range matches {
err = rt.State.Workspace.Export(match, dst)
if err != nil {
- return nil
+ return err
}
}
}
--- a/workspace/fileio.go Sat Jul 27 14:15:34 2019 -0500
+++ b/workspace/fileio.go Sat Jul 27 15:19:35 2019 -0500
@@ -114,13 +114,20 @@
if file.IsDir() {
return ws.copyDir(src, realDst, 0644)
- } else {
- return ws.copyFile(src, realDst, 0644)
}
+
+ return ws.copyFile(src, realDst, 0644)
}
func (ws *Workspace) Export(src, dst string) error {
- realSrc := filepath.Join(ws.volumePath, src)
+ file, err := os.Stat(src)
+ if err != nil {
+ return err
+ }
- return ws.copyFile(realSrc, dst, 0644)
+ if file.IsDir() {
+ return ws.copyDir(src, dst, 0644)
+ }
+
+ return ws.copyFile(src, dst, 0644)
}