func Download(client concourse.Client, output Output) { path := output.Path pipe := output.Pipe response, err := client.HTTPClient().Get(pipe.ReadURL) if err != nil { fmt.Fprintln(os.Stderr, "download request failed:", err) } defer response.Body.Close() if response.StatusCode != http.StatusOK { fmt.Fprintln(os.Stderr, badResponseError("downloading bits", response)) panic("unexpected-response-code") } err = os.MkdirAll(path, 0755) if err != nil { panic(err) } err = tarStreamTo(path, response.Body) if err != nil { panic(err) } }
func Upload(client concourse.Client, input Input, excludeIgnored bool) { path := input.Path pipe := input.Pipe var files []string var err error if excludeIgnored { files, err = getGitFiles(path) if err != nil { fmt.Fprintln(os.Stderr, "could not determine ignored files:", err) return } } else { files = []string{"."} } archive, err := tarStreamFrom(path, files) if err != nil { fmt.Fprintln(os.Stderr, "could create tar stream:", err) return } defer archive.Close() upload, err := http.NewRequest("PUT", pipe.WriteURL, archive) if err != nil { panic(err) } response, err := client.HTTPClient().Do(upload) if err != nil { fmt.Fprintln(os.Stderr, "upload request failed:", err) return } defer response.Body.Close() if response.StatusCode != http.StatusOK { fmt.Fprintln(os.Stderr, badResponseError("uploading bits", response)) } }