mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-16 10:34:06 -08:00
ddefee52dc
Note that by just running `make update-go-deps`, the K8s Go client was set to `k8s.io/client-go v11.0.0+incompatible`. However, that doesn't play well with `k8s.io/apimachinery v0.18.5`. I the manually changed the Go client line to `k8s.io/client-go v0.18.5`, which made everything work. I guess Go Modules got confused by the ginormous v11.0.0 version tag. Or it is a problem that pulling k8s.io/client-go with git results in a rather old repo without the v0.18.5 tag. github.com/kubernetes/client-go has all the right tags. I actually don't understand how Go Modules still correctly figures out the source from the `k8s.io/client-go v0.18.5` line. If one of the reviewers could enlighten me, I'd much appreciate it. Signed-off-by: beorn7 <beorn@grafana.com>
252 lines
5.3 KiB
Go
252 lines
5.3 KiB
Go
// +build go1.8
|
|
|
|
package nethttp
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
type statusCodeTracker struct {
|
|
http.ResponseWriter
|
|
status int
|
|
}
|
|
|
|
func (w *statusCodeTracker) WriteHeader(status int) {
|
|
w.status = status
|
|
w.ResponseWriter.WriteHeader(status)
|
|
}
|
|
|
|
func (w *statusCodeTracker) Write(b []byte) (int, error) {
|
|
return w.ResponseWriter.Write(b)
|
|
}
|
|
|
|
// wrappedResponseWriter returns a wrapped version of the original
|
|
// ResponseWriter and only implements the same combination of additional
|
|
// interfaces as the original. This implementation is based on
|
|
// https://github.com/felixge/httpsnoop.
|
|
func (w *statusCodeTracker) wrappedResponseWriter() http.ResponseWriter {
|
|
var (
|
|
hj, i0 = w.ResponseWriter.(http.Hijacker)
|
|
cn, i1 = w.ResponseWriter.(http.CloseNotifier)
|
|
pu, i2 = w.ResponseWriter.(http.Pusher)
|
|
fl, i3 = w.ResponseWriter.(http.Flusher)
|
|
rf, i4 = w.ResponseWriter.(io.ReaderFrom)
|
|
)
|
|
|
|
switch {
|
|
case !i0 && !i1 && !i2 && !i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
}{w}
|
|
case !i0 && !i1 && !i2 && !i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
io.ReaderFrom
|
|
}{w, rf}
|
|
case !i0 && !i1 && !i2 && i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Flusher
|
|
}{w, fl}
|
|
case !i0 && !i1 && !i2 && i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Flusher
|
|
io.ReaderFrom
|
|
}{w, fl, rf}
|
|
case !i0 && !i1 && i2 && !i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Pusher
|
|
}{w, pu}
|
|
case !i0 && !i1 && i2 && !i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Pusher
|
|
io.ReaderFrom
|
|
}{w, pu, rf}
|
|
case !i0 && !i1 && i2 && i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Pusher
|
|
http.Flusher
|
|
}{w, pu, fl}
|
|
case !i0 && !i1 && i2 && i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Pusher
|
|
http.Flusher
|
|
io.ReaderFrom
|
|
}{w, pu, fl, rf}
|
|
case !i0 && i1 && !i2 && !i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.CloseNotifier
|
|
}{w, cn}
|
|
case !i0 && i1 && !i2 && !i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.CloseNotifier
|
|
io.ReaderFrom
|
|
}{w, cn, rf}
|
|
case !i0 && i1 && !i2 && i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.CloseNotifier
|
|
http.Flusher
|
|
}{w, cn, fl}
|
|
case !i0 && i1 && !i2 && i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.CloseNotifier
|
|
http.Flusher
|
|
io.ReaderFrom
|
|
}{w, cn, fl, rf}
|
|
case !i0 && i1 && i2 && !i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.CloseNotifier
|
|
http.Pusher
|
|
}{w, cn, pu}
|
|
case !i0 && i1 && i2 && !i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.CloseNotifier
|
|
http.Pusher
|
|
io.ReaderFrom
|
|
}{w, cn, pu, rf}
|
|
case !i0 && i1 && i2 && i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.CloseNotifier
|
|
http.Pusher
|
|
http.Flusher
|
|
}{w, cn, pu, fl}
|
|
case !i0 && i1 && i2 && i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.CloseNotifier
|
|
http.Pusher
|
|
http.Flusher
|
|
io.ReaderFrom
|
|
}{w, cn, pu, fl, rf}
|
|
case i0 && !i1 && !i2 && !i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
}{w, hj}
|
|
case i0 && !i1 && !i2 && !i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
io.ReaderFrom
|
|
}{w, hj, rf}
|
|
case i0 && !i1 && !i2 && i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.Flusher
|
|
}{w, hj, fl}
|
|
case i0 && !i1 && !i2 && i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.Flusher
|
|
io.ReaderFrom
|
|
}{w, hj, fl, rf}
|
|
case i0 && !i1 && i2 && !i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.Pusher
|
|
}{w, hj, pu}
|
|
case i0 && !i1 && i2 && !i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.Pusher
|
|
io.ReaderFrom
|
|
}{w, hj, pu, rf}
|
|
case i0 && !i1 && i2 && i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.Pusher
|
|
http.Flusher
|
|
}{w, hj, pu, fl}
|
|
case i0 && !i1 && i2 && i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.Pusher
|
|
http.Flusher
|
|
io.ReaderFrom
|
|
}{w, hj, pu, fl, rf}
|
|
case i0 && i1 && !i2 && !i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.CloseNotifier
|
|
}{w, hj, cn}
|
|
case i0 && i1 && !i2 && !i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.CloseNotifier
|
|
io.ReaderFrom
|
|
}{w, hj, cn, rf}
|
|
case i0 && i1 && !i2 && i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.CloseNotifier
|
|
http.Flusher
|
|
}{w, hj, cn, fl}
|
|
case i0 && i1 && !i2 && i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.CloseNotifier
|
|
http.Flusher
|
|
io.ReaderFrom
|
|
}{w, hj, cn, fl, rf}
|
|
case i0 && i1 && i2 && !i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.CloseNotifier
|
|
http.Pusher
|
|
}{w, hj, cn, pu}
|
|
case i0 && i1 && i2 && !i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.CloseNotifier
|
|
http.Pusher
|
|
io.ReaderFrom
|
|
}{w, hj, cn, pu, rf}
|
|
case i0 && i1 && i2 && i3 && !i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.CloseNotifier
|
|
http.Pusher
|
|
http.Flusher
|
|
}{w, hj, cn, pu, fl}
|
|
case i0 && i1 && i2 && i3 && i4:
|
|
return struct {
|
|
http.ResponseWriter
|
|
http.Hijacker
|
|
http.CloseNotifier
|
|
http.Pusher
|
|
http.Flusher
|
|
io.ReaderFrom
|
|
}{w, hj, cn, pu, fl, rf}
|
|
default:
|
|
return struct {
|
|
http.ResponseWriter
|
|
}{w}
|
|
}
|
|
}
|