From 2ed3ee45248041f617939b74dd7f25b9647a05a7 Mon Sep 17 00:00:00 2001 From: Antoine Pelisse Date: Wed, 23 Aug 2017 09:34:02 -0700 Subject: [PATCH] client-go cache: Make caching layer Unwrappable Kubernetes-commit: a804d440c3dfab8820c7f2d231dcaecb201be7b5 --- transport/round_trippers.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/transport/round_trippers.go b/transport/round_trippers.go index e6bb84e1..2ee605d7 100644 --- a/transport/round_trippers.go +++ b/transport/round_trippers.go @@ -86,12 +86,8 @@ type requestCanceler interface { CancelRequest(*http.Request) } -type authProxyRoundTripper struct { - username string - groups []string - extra map[string][]string - - rt http.RoundTripper +type cacheRoundTripper struct { + rt *httpcache.Transport } // NewCacheRoundTripper creates a roundtripper that reads the ETag on @@ -105,7 +101,21 @@ func NewCacheRoundTripper(cacheDir string, rt http.RoundTripper) http.RoundTripp t := httpcache.NewTransport(diskcache.NewWithDiskv(d)) t.Transport = rt - return t + return &cacheRoundTripper{rt: t} +} + +func (rt *cacheRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + return rt.rt.RoundTrip(req) +} + +func (rt *cacheRoundTripper) WrappedRoundTripper() http.RoundTripper { return rt.rt.Transport } + +type authProxyRoundTripper struct { + username string + groups []string + extra map[string][]string + + rt http.RoundTripper } // NewAuthProxyRoundTripper provides a roundtripper which will add auth proxy fields to requests for