// fetchFile fetches the specified directory from the given buildlet, and // writes the first file it finds in that directory to dest. func (b *Build) fetchFile(client *buildlet.Client, dest, dir string) error { b.logf("Downloading file from %q.", dir) tgz, err := client.GetTar(dir) if err != nil { return err } defer tgz.Close() zr, err := gzip.NewReader(tgz) if err != nil { return err } tr := tar.NewReader(zr) for { h, err := tr.Next() if err == io.EOF { return io.ErrUnexpectedEOF } if err != nil { return err } if !h.FileInfo().IsDir() { break } } return b.writeFile(dest, tr) }
func (b *Build) fetchZip(client *buildlet.Client) error { b.logf("Downloading tarball and re-compressing as zip.") tgz, err := client.GetTar(".") if err != nil { return err } defer tgz.Close() filename := *version + "." + b.String() + ".zip" f, err := os.Create(filename) if err != nil { return err } if err := tgzToZip(f, tgz); err != nil { f.Close() return err } if err := f.Close(); err != nil { return err } b.logf("Wrote %q.", filename) return nil }
func (b *Build) fetchTarball(client *buildlet.Client) error { b.logf("Downloading tarball.") tgz, err := client.GetTar(".") if err != nil { return err } filename := *version + "." + b.String() + ".tar.gz" return b.writeFile(filename, tgz) }
func (p *reverseBuildletPool) cleanedBuildlet(b *buildlet.Client, el eventTimeLogger) (*buildlet.Client, error) { el.logEventTime("got_machine") // Clean up any files from previous builds. if err := b.RemoveAll("."); err != nil { b.Close() return nil, err } el.logEventTime("cleaned_up") return b, nil }
func destroyCloseBuildlet(bc *buildlet.Client) { bc.Destroy() bc.Close() }