github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/api/cloudcontroller/pipebomb.go (about) 1 package cloudcontroller 2 3 import ( 4 "io" 5 6 "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" 7 ) 8 9 // Pipebomb is a wrapper around an io.Pipe's io.ReadCloser that turns it into a 10 // ReadSeeker that errors on Seek calls. 11 type Pipebomb struct { 12 io.ReadCloser 13 } 14 15 // Seek returns a PipeSeekError; allowing the top level calling function to 16 // handle the retry instead of seeking back to the beginning of the Reader. 17 func (*Pipebomb) Seek(offset int64, whence int) (int64, error) { 18 return 0, ccerror.PipeSeekError{} 19 } 20 21 // NewPipeBomb returns an io.WriteCloser that can be used to stream data to a 22 // the Pipebomb. 23 func NewPipeBomb() (*Pipebomb, io.WriteCloser) { 24 writerOutput, writerInput := io.Pipe() 25 return &Pipebomb{ReadCloser: writerOutput}, writerInput 26 }