gitlab.com/jfprevost/gitlab-runner-notlscheck@v11.11.4+incompatible/cache/s3/bucket_location_tripper.go (about) 1 package s3 2 3 import ( 4 "bytes" 5 "encoding/xml" 6 "io/ioutil" 7 "net/http" 8 ) 9 10 type bucketLocationTripper struct { 11 bucketLocation string 12 } 13 14 // The Minio Golang library always attempts to query the bucket location and 15 // currently has no way of statically setting that value. To avoid that 16 // lookup, the Runner cache uses the library only to generate the URLs, 17 // forgoing the library's API for uploading and downloading files. The custom 18 // Roundtripper stubs out any network requests that would normally be made via 19 // the library. 20 func (b *bucketLocationTripper) RoundTrip(req *http.Request) (res *http.Response, err error) { 21 var buffer bytes.Buffer 22 xml.NewEncoder(&buffer).Encode(b.bucketLocation) 23 res = &http.Response{ 24 StatusCode: http.StatusOK, 25 Body: ioutil.NopCloser(&buffer), 26 } 27 return 28 } 29 30 func (b *bucketLocationTripper) CancelRequest(req *http.Request) { 31 // Do nothing 32 }