Commit d857c9cc authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/amazon/chroot: implement UploadDir for chroot communicator

parent 1010c8ae
......@@ -70,6 +70,38 @@ func (c *Communicator) Upload(dst string, r io.Reader) error {
return nil
}
func (c *Communicator) UploadDir(dst string, src string, exclude []string) error {
walkFn := func(fullPath string, info os.FileInfo, err error) error {
if err != nil {
return err
}
path, err := filepath.Rel(src, fullPath)
if err != nil {
return err
}
for _, e := range exclude {
if e == path {
log.Printf("Skipping excluded file: %s", path)
return nil
}
}
dstPath := filepath.Join(dst, path)
f, err := os.Open(fullPath)
if err != nil {
return err
}
defer f.Close()
return c.Upload(dstPath, f)
}
log.Printf("Uploading directory '%s' to '%s'", src, dst)
return filepath.Walk(src, walkFn)
}
func (c *Communicator) Download(src string, w io.Writer) error {
src = filepath.Join(c.Chroot, src)
log.Printf("Downloading from chroot dir: %s", src)
......
......@@ -204,6 +204,10 @@ func (c *comm) Upload(path string, input io.Reader) error {
return nil
}
func (c *comm) UploadDir(dst string, src string, excl []string) error {
return nil
}
func (c *comm) Download(string, io.Writer) error {
panic("not implemented yet")
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment