From d7f469601fda50ab2e1e9e59adaae088af39a98e Mon Sep 17 00:00:00 2001 From: Antoine Pelisse Date: Fri, 9 Jun 2017 10:30:47 -0700 Subject: [PATCH 1/4] c-go: Use http Etag cache Add a new command-line cachedir flag to specify where to store the http cache responses. This cache will only be used for OpenAPI Swagger spec for now (as this is the only end-point that returns an ETag). Kubernetes-commit: d7bba25d4a42f346f1963c86fc0dab43aa4f242e --- rest/config.go | 4 ++++ rest/config_test.go | 1 + rest/transport.go | 1 + tools/clientcmd/client_config.go | 5 +++++ tools/clientcmd/overrides.go | 8 ++++++++ transport/BUILD | 3 +++ transport/config.go | 4 ++++ transport/round_trippers.go | 17 +++++++++++++++++ 8 files changed, 43 insertions(+) diff --git a/rest/config.go b/rest/config.go index dca7333d..627a9cc9 100644 --- a/rest/config.go +++ b/rest/config.go @@ -71,6 +71,10 @@ type Config struct { // TODO: demonstrate an OAuth2 compatible client. BearerToken string + // CacheDir is the directory where we'll store HTTP cached responses. + // If set to empty string, no caching mechanism will be used. + CacheDir string + // Impersonate is the configuration that RESTClient will use for impersonation. Impersonate ImpersonationConfig diff --git a/rest/config_test.go b/rest/config_test.go index f04135a4..f20ed722 100644 --- a/rest/config_test.go +++ b/rest/config_test.go @@ -249,6 +249,7 @@ func TestAnonymousConfig(t *testing.T) { expected.BearerToken = "" expected.Username = "" expected.Password = "" + expected.CacheDir = "" expected.AuthProvider = nil expected.AuthConfigPersister = nil expected.TLSClientConfig.CertData = nil diff --git a/rest/transport.go b/rest/transport.go index ba43752b..4c5b1648 100644 --- a/rest/transport.go +++ b/rest/transport.go @@ -89,6 +89,7 @@ func (c *Config) TransportConfig() (*transport.Config, error) { }, Username: c.Username, Password: c.Password, + CacheDir: c.CacheDir, BearerToken: c.BearerToken, Impersonate: transport.ImpersonationConfig{ UserName: c.Impersonate.UserName, diff --git a/tools/clientcmd/client_config.go b/tools/clientcmd/client_config.go index a8698af2..9646c6b7 100644 --- a/tools/clientcmd/client_config.go +++ b/tools/clientcmd/client_config.go @@ -22,6 +22,7 @@ import ( "io/ioutil" "net/url" "os" + "path/filepath" "strings" "github.com/golang/glog" @@ -31,16 +32,19 @@ import ( restclient "k8s.io/client-go/rest" clientauth "k8s.io/client-go/tools/auth" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" + "k8s.io/client-go/util/homedir" ) var ( // ClusterDefaults has the same behavior as the old EnvVar and DefaultCluster fields // DEPRECATED will be replaced ClusterDefaults = clientcmdapi.Cluster{Server: getDefaultServer()} + cacheDirDefault = filepath.Join(homedir.HomeDir(), ".kube", "http-cache") // DefaultClientConfig represents the legacy behavior of this package for defaulting // DEPRECATED will be replace DefaultClientConfig = DirectClientConfig{*clientcmdapi.NewConfig(), "", &ConfigOverrides{ ClusterDefaults: ClusterDefaults, + CacheDir: cacheDirDefault, }, nil, NewDefaultClientConfigLoadingRules(), promptedCredentials{}} ) @@ -131,6 +135,7 @@ func (config *DirectClientConfig) ClientConfig() (*restclient.Config, error) { clientConfig := &restclient.Config{} clientConfig.Host = configClusterInfo.Server + clientConfig.CacheDir = config.overrides.CacheDir if len(config.overrides.Timeout) > 0 { timeout, err := ParseTimeout(config.overrides.Timeout) diff --git a/tools/clientcmd/overrides.go b/tools/clientcmd/overrides.go index 963ac8fa..25ab1ea1 100644 --- a/tools/clientcmd/overrides.go +++ b/tools/clientcmd/overrides.go @@ -17,11 +17,13 @@ limitations under the License. package clientcmd import ( + "path/filepath" "strconv" "github.com/spf13/pflag" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" + "k8s.io/client-go/util/homedir" ) // ConfigOverrides holds values that should override whatever information is pulled from the actual Config object. You can't @@ -34,6 +36,7 @@ type ConfigOverrides struct { Context clientcmdapi.Context CurrentContext string Timeout string + CacheDir string } // ConfigOverrideFlags holds the flag names to be used for binding command line flags. Notice that this structure tightly @@ -44,6 +47,7 @@ type ConfigOverrideFlags struct { ContextOverrideFlags ContextOverrideFlags CurrentContext FlagInfo Timeout FlagInfo + CacheDir FlagInfo } // AuthOverrideFlags holds the flag names to be used for binding command line flags for AuthInfo objects @@ -146,10 +150,12 @@ const ( FlagUsername = "username" FlagPassword = "password" FlagTimeout = "request-timeout" + FlagCacheDir = "cachedir" ) // RecommendedConfigOverrideFlags is a convenience method to return recommended flag names prefixed with a string of your choosing func RecommendedConfigOverrideFlags(prefix string) ConfigOverrideFlags { + defaultCacheDir := filepath.Join(homedir.HomeDir(), ".kube", "http-cache") return ConfigOverrideFlags{ AuthOverrideFlags: RecommendedAuthOverrideFlags(prefix), ClusterOverrideFlags: RecommendedClusterOverrideFlags(prefix), @@ -157,6 +163,7 @@ func RecommendedConfigOverrideFlags(prefix string) ConfigOverrideFlags { CurrentContext: FlagInfo{prefix + FlagContext, "", "", "The name of the kubeconfig context to use"}, Timeout: FlagInfo{prefix + FlagTimeout, "", "0", "The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests."}, + CacheDir: FlagInfo{prefix + FlagCacheDir, "", defaultCacheDir, "Path to http-cache directory"}, } } @@ -198,6 +205,7 @@ func BindOverrideFlags(overrides *ConfigOverrides, flags *pflag.FlagSet, flagNam BindContextFlags(&overrides.Context, flags, flagNames.ContextOverrideFlags) flagNames.CurrentContext.BindStringFlag(flags, &overrides.CurrentContext) flagNames.Timeout.BindStringFlag(flags, &overrides.Timeout) + flagNames.CacheDir.BindStringFlag(flags, &overrides.CacheDir) } // BindAuthInfoFlags is a convenience method to bind the specified flags to their associated variables diff --git a/transport/BUILD b/transport/BUILD index 1a54f483..c17299d5 100644 --- a/transport/BUILD +++ b/transport/BUILD @@ -30,6 +30,9 @@ go_library( tags = ["automanaged"], deps = [ "//vendor/github.com/golang/glog:go_default_library", + "//vendor/github.com/gregjones/httpcache:go_default_library", + "//vendor/github.com/gregjones/httpcache/diskcache:go_default_library", + "//vendor/github.com/peterbourgon/diskv:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library", ], ) diff --git a/transport/config.go b/transport/config.go index 820594ba..e34d6e8c 100644 --- a/transport/config.go +++ b/transport/config.go @@ -34,6 +34,10 @@ type Config struct { // Bearer token for authentication BearerToken string + // CacheDir is the directory where we'll store HTTP cached responses. + // If set to empty string, no caching mechanism will be used. + CacheDir string + // Impersonate is the config that this Config will impersonate using Impersonate ImpersonationConfig diff --git a/transport/round_trippers.go b/transport/round_trippers.go index c728b187..2394c42c 100644 --- a/transport/round_trippers.go +++ b/transport/round_trippers.go @@ -23,6 +23,9 @@ import ( "time" "github.com/golang/glog" + "github.com/gregjones/httpcache" + "github.com/gregjones/httpcache/diskcache" + "github.com/peterbourgon/diskv" utilnet "k8s.io/apimachinery/pkg/util/net" ) @@ -56,6 +59,9 @@ func HTTPWrappersForConfig(config *Config, rt http.RoundTripper) (http.RoundTrip len(config.Impersonate.Extra) > 0 { rt = NewImpersonatingRoundTripper(config.Impersonate, rt) } + if len(config.CacheDir) > 0 { + rt = NewCacheRoundTripper(config.CacheDir, rt) + } return rt, nil } @@ -87,6 +93,17 @@ type authProxyRoundTripper struct { rt http.RoundTripper } +// NewCacheRoundTripper creates a roundtripper that reads the ETag on +// response headers and send the If-None-Match header on subsequent +// corresponding requests. +func NewCacheRoundTripper(cacheDir string, rt http.RoundTripper) http.RoundTripper { + d := diskv.New(diskv.Options{BasePath: cacheDir}) + t := httpcache.NewTransport(diskcache.NewWithDiskv(d)) + t.Transport = rt + + return t +} + // NewAuthProxyRoundTripper provides a roundtripper which will add auth proxy fields to requests for // authentication terminating proxy cases // assuming you pull the user from the context: From 5e0e877ac2abfc77f432af15e8305d40921afbee Mon Sep 17 00:00:00 2001 From: Kubernetes Publisher Date: Tue, 29 Aug 2017 12:50:18 +0000 Subject: [PATCH 2/4] sync: reset Godeps/Godeps.json --- Godeps/Godeps.json | 936 ++++++++++++++++----------------------------- 1 file changed, 324 insertions(+), 612 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 34854614..ec202a5d 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,614 +1,326 @@ { - "ImportPath": "k8s.io/client-go", - "GoVersion": "go1.8", - "GodepVersion": "v79", - "Packages": [ - "./..." - ], - "Deps": [ - { - "ImportPath": "cloud.google.com/go/compute/metadata", - "Rev": "3b1ae45394a234c385be014e9a488f2bb6eef821" - }, - { - "ImportPath": "cloud.google.com/go/internal", - "Rev": "3b1ae45394a234c385be014e9a488f2bb6eef821" - }, - { - "ImportPath": "github.com/Azure/go-autorest/autorest", - "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d" - }, - { - "ImportPath": "github.com/Azure/go-autorest/autorest/adal", - "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d" - }, - { - "ImportPath": "github.com/Azure/go-autorest/autorest/azure", - "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d" - }, - { - "ImportPath": "github.com/Azure/go-autorest/autorest/date", - "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d" - }, - { - "ImportPath": "github.com/PuerkitoBio/purell", - "Rev": "8a290539e2e8629dbc4e6bad948158f790ec31f4" - }, - { - "ImportPath": "github.com/PuerkitoBio/urlesc", - "Rev": "5bd2802263f21d8788851d5305584c82a5c75d7e" - }, - { - "ImportPath": "github.com/coreos/go-oidc/http", - "Rev": "be73733bb8cc830d0205609b95d125215f8e9c70" - }, - { - "ImportPath": "github.com/coreos/go-oidc/jose", - "Rev": "be73733bb8cc830d0205609b95d125215f8e9c70" - }, - { - "ImportPath": "github.com/coreos/go-oidc/key", - "Rev": "be73733bb8cc830d0205609b95d125215f8e9c70" - }, - { - "ImportPath": "github.com/coreos/go-oidc/oauth2", - "Rev": "be73733bb8cc830d0205609b95d125215f8e9c70" - }, - { - "ImportPath": "github.com/coreos/go-oidc/oidc", - "Rev": "be73733bb8cc830d0205609b95d125215f8e9c70" - }, - { - "ImportPath": "github.com/coreos/pkg/health", - "Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8" - }, - { - "ImportPath": "github.com/coreos/pkg/httputil", - "Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8" - }, - { - "ImportPath": "github.com/coreos/pkg/timeutil", - "Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8" - }, - { - "ImportPath": "github.com/davecgh/go-spew/spew", - "Rev": "782f4967f2dc4564575ca782fe2d04090b5faca8" - }, - { - "ImportPath": "github.com/dgrijalva/jwt-go", - "Rev": "01aeca54ebda6e0fbfafd0a524d234159c05ec20" - }, - { - "ImportPath": "github.com/docker/spdystream", - "Rev": "449fdfce4d962303d702fec724ef0ad181c92528" - }, - { - "ImportPath": "github.com/docker/spdystream/spdy", - "Rev": "449fdfce4d962303d702fec724ef0ad181c92528" - }, - { - "ImportPath": "github.com/emicklei/go-restful", - "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" - }, - { - "ImportPath": "github.com/emicklei/go-restful-swagger12", - "Rev": "dcef7f55730566d41eae5db10e7d6981829720f6" - }, - { - "ImportPath": "github.com/emicklei/go-restful/log", - "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" - }, - { - "ImportPath": "github.com/ghodss/yaml", - "Rev": "73d445a93680fa1a78ae23a5839bad48f32ba1ee" - }, - { - "ImportPath": "github.com/go-openapi/jsonpointer", - "Rev": "46af16f9f7b149af66e5d1bd010e3574dc06de98" - }, - { - "ImportPath": "github.com/go-openapi/jsonreference", - "Rev": "13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272" - }, - { - "ImportPath": "github.com/go-openapi/spec", - "Rev": "6aced65f8501fe1217321abf0749d354824ba2ff" - }, - { - "ImportPath": "github.com/go-openapi/swag", - "Rev": "1d0bd113de87027671077d3c71eb3ac5d7dbba72" - }, - { - "ImportPath": "github.com/gogo/protobuf/proto", - "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" - }, - { - "ImportPath": "github.com/gogo/protobuf/sortkeys", - "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" - }, - { - "ImportPath": "github.com/golang/glog", - "Rev": "44145f04b68cf362d9c4df2182967c2275eaefed" - }, - { - "ImportPath": "github.com/golang/groupcache/lru", - "Rev": "02826c3e79038b59d737d3b1c0a1d937f71a4433" - }, - { - "ImportPath": "github.com/golang/protobuf/proto", - "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" - }, - { - "ImportPath": "github.com/golang/protobuf/ptypes", - "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" - }, - { - "ImportPath": "github.com/golang/protobuf/ptypes/any", - "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" - }, - { - "ImportPath": "github.com/golang/protobuf/ptypes/duration", - "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" - }, - { - "ImportPath": "github.com/golang/protobuf/ptypes/timestamp", - "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" - }, - { - "ImportPath": "github.com/google/gofuzz", - "Rev": "44d81051d367757e1c7c6a5a86423ece9afcf63c" - }, - { - "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" - }, - { - "ImportPath": "github.com/googleapis/gnostic/compiler", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" - }, - { - "ImportPath": "github.com/googleapis/gnostic/extensions", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" - }, - { - "ImportPath": "github.com/hashicorp/golang-lru", - "Rev": "a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4" - }, - { - "ImportPath": "github.com/hashicorp/golang-lru/simplelru", - "Rev": "a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4" - }, - { - "ImportPath": "github.com/howeyc/gopass", - "Rev": "bf9dde6d0d2c004a008c27aaee91170c786f6db8" - }, - { - "ImportPath": "github.com/imdario/mergo", - "Rev": "6633656539c1639d9d78127b7d47c622b5d7b6dc" - }, - { - "ImportPath": "github.com/jonboulle/clockwork", - "Rev": "72f9bd7c4e0c2a40055ab3d0f09654f730cce982" - }, - { - "ImportPath": "github.com/juju/ratelimit", - "Rev": "5b9ff866471762aa2ab2dced63c9fb6f53921342" - }, - { - "ImportPath": "github.com/mailru/easyjson/buffer", - "Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0" - }, - { - "ImportPath": "github.com/mailru/easyjson/jlexer", - "Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0" - }, - { - "ImportPath": "github.com/mailru/easyjson/jwriter", - "Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0" - }, - { - "ImportPath": "github.com/pmezard/go-difflib/difflib", - "Rev": "d8ed2627bdf02c080bf22230dbb337003b7aba2d" - }, - { - "ImportPath": "github.com/spf13/pflag", - "Rev": "9ff6c6923cfffbcd502984b8e0c80539a94968b7" - }, - { - "ImportPath": "github.com/stretchr/testify/assert", - "Rev": "f6abca593680b2315d2075e0f5e2a9751e3f431a" - }, - { - "ImportPath": "github.com/ugorji/go/codec", - "Rev": "ded73eae5db7e7a0ef6f55aace87a2873c5d2b74" - }, - { - "ImportPath": "golang.org/x/crypto/ssh/terminal", - "Rev": "d172538b2cfce0c13cee31e647d0367aa8cd2486" - }, - { - "ImportPath": "golang.org/x/net/context", - "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" - }, - { - "ImportPath": "golang.org/x/net/context/ctxhttp", - "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" - }, - { - "ImportPath": "golang.org/x/net/http2", - "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" - }, - { - "ImportPath": "golang.org/x/net/http2/hpack", - "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" - }, - { - "ImportPath": "golang.org/x/net/idna", - "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" - }, - { - "ImportPath": "golang.org/x/net/lex/httplex", - "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" - }, - { - "ImportPath": "golang.org/x/oauth2", - "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" - }, - { - "ImportPath": "golang.org/x/oauth2/google", - "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" - }, - { - "ImportPath": "golang.org/x/oauth2/internal", - "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" - }, - { - "ImportPath": "golang.org/x/oauth2/jws", - "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" - }, - { - "ImportPath": "golang.org/x/oauth2/jwt", - "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" - }, - { - "ImportPath": "golang.org/x/sys/unix", - "Rev": "7a4fde3fda8ef580a89dbae8138c26041be14299" - }, - { - "ImportPath": "golang.org/x/text/cases", - "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" - }, - { - "ImportPath": "golang.org/x/text/internal/tag", - "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" - }, - { - "ImportPath": "golang.org/x/text/language", - "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" - }, - { - "ImportPath": "golang.org/x/text/runes", - "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" - }, - { - "ImportPath": "golang.org/x/text/secure/bidirule", - "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" - }, - { - "ImportPath": "golang.org/x/text/secure/precis", - "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" - }, - { - "ImportPath": "golang.org/x/text/transform", - "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" - }, - { - "ImportPath": "golang.org/x/text/unicode/bidi", - "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" - }, - { - "ImportPath": "golang.org/x/text/unicode/norm", - "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" - }, - { - "ImportPath": "golang.org/x/text/width", - "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" - }, - { - "ImportPath": "gopkg.in/inf.v0", - "Rev": "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4" - }, - { - "ImportPath": "gopkg.in/yaml.v2", - "Rev": "53feefa2559fb8dfa8d81baad31be332c97d6c77" - }, - { - "ImportPath": "k8s.io/api/admissionregistration/v1alpha1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/apps/v1beta1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/apps/v1beta2", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/authentication/v1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/authentication/v1beta1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/authorization/v1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/authorization/v1beta1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/autoscaling/v1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/autoscaling/v2alpha1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/batch/v1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/batch/v2alpha1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/certificates/v1beta1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/core/v1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/extensions/v1beta1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/imagepolicy/v1alpha1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/networking/v1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/policy/v1beta1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/rbac/v1alpha1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/rbac/v1beta1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/scheduling/v1alpha1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/settings/v1alpha1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/storage/v1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/api/storage/v1beta1", - "Rev": "f30e293246921de7f4ee46bb65b8762b2f890fc4" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/equality", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/errors", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/meta", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/resource", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apimachinery", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/conversion", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/fields", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/labels", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/selection", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/types", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/cache", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/clock", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/diff", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/errors", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/framer", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/intstr", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/json", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/net", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/runtime", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/sets", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/validation", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/wait", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/yaml", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/version", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/watch", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", - "Rev": "abee1a2f97bdbf7f5c1bd6f363a3d1478bb1e8ec" - }, - { - "ImportPath": "k8s.io/kube-openapi/pkg/common", - "Rev": "80f07ef71bb4f781233c65aa8d0369e4ecafab87" - } - ] + "ImportPath": "k8s.io/client-go", + "GoVersion": "go1.8", + "GodepVersion": "v79", + "Packages": [ + "./..." + ], + "Deps": [ + { + "ImportPath": "cloud.google.com/go/compute/metadata", + "Rev": "3b1ae45394a234c385be014e9a488f2bb6eef821" + }, + { + "ImportPath": "cloud.google.com/go/internal", + "Rev": "3b1ae45394a234c385be014e9a488f2bb6eef821" + }, + { + "ImportPath": "github.com/Azure/go-autorest/autorest", + "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d" + }, + { + "ImportPath": "github.com/Azure/go-autorest/autorest/adal", + "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d" + }, + { + "ImportPath": "github.com/Azure/go-autorest/autorest/azure", + "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d" + }, + { + "ImportPath": "github.com/Azure/go-autorest/autorest/date", + "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d" + }, + { + "ImportPath": "github.com/PuerkitoBio/purell", + "Rev": "8a290539e2e8629dbc4e6bad948158f790ec31f4" + }, + { + "ImportPath": "github.com/PuerkitoBio/urlesc", + "Rev": "5bd2802263f21d8788851d5305584c82a5c75d7e" + }, + { + "ImportPath": "github.com/coreos/go-oidc/http", + "Rev": "a4973d9a4225417aecf5d450a9522f00c1f7130f" + }, + { + "ImportPath": "github.com/coreos/go-oidc/jose", + "Rev": "a4973d9a4225417aecf5d450a9522f00c1f7130f" + }, + { + "ImportPath": "github.com/coreos/go-oidc/key", + "Rev": "a4973d9a4225417aecf5d450a9522f00c1f7130f" + }, + { + "ImportPath": "github.com/coreos/go-oidc/oauth2", + "Rev": "a4973d9a4225417aecf5d450a9522f00c1f7130f" + }, + { + "ImportPath": "github.com/coreos/go-oidc/oidc", + "Rev": "a4973d9a4225417aecf5d450a9522f00c1f7130f" + }, + { + "ImportPath": "github.com/coreos/pkg/health", + "Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8" + }, + { + "ImportPath": "github.com/coreos/pkg/httputil", + "Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8" + }, + { + "ImportPath": "github.com/coreos/pkg/timeutil", + "Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8" + }, + { + "ImportPath": "github.com/davecgh/go-spew/spew", + "Rev": "782f4967f2dc4564575ca782fe2d04090b5faca8" + }, + { + "ImportPath": "github.com/dgrijalva/jwt-go", + "Rev": "01aeca54ebda6e0fbfafd0a524d234159c05ec20" + }, + { + "ImportPath": "github.com/docker/spdystream", + "Rev": "449fdfce4d962303d702fec724ef0ad181c92528" + }, + { + "ImportPath": "github.com/docker/spdystream/spdy", + "Rev": "449fdfce4d962303d702fec724ef0ad181c92528" + }, + { + "ImportPath": "github.com/emicklei/go-restful", + "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" + }, + { + "ImportPath": "github.com/emicklei/go-restful-swagger12", + "Rev": "dcef7f55730566d41eae5db10e7d6981829720f6" + }, + { + "ImportPath": "github.com/emicklei/go-restful/log", + "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" + }, + { + "ImportPath": "github.com/ghodss/yaml", + "Rev": "73d445a93680fa1a78ae23a5839bad48f32ba1ee" + }, + { + "ImportPath": "github.com/go-openapi/jsonpointer", + "Rev": "46af16f9f7b149af66e5d1bd010e3574dc06de98" + }, + { + "ImportPath": "github.com/go-openapi/jsonreference", + "Rev": "13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272" + }, + { + "ImportPath": "github.com/go-openapi/spec", + "Rev": "6aced65f8501fe1217321abf0749d354824ba2ff" + }, + { + "ImportPath": "github.com/go-openapi/swag", + "Rev": "1d0bd113de87027671077d3c71eb3ac5d7dbba72" + }, + { + "ImportPath": "github.com/gogo/protobuf/proto", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/sortkeys", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/golang/glog", + "Rev": "44145f04b68cf362d9c4df2182967c2275eaefed" + }, + { + "ImportPath": "github.com/golang/groupcache/lru", + "Rev": "02826c3e79038b59d737d3b1c0a1d937f71a4433" + }, + { + "ImportPath": "github.com/golang/protobuf/proto", + "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" + }, + { + "ImportPath": "github.com/golang/protobuf/ptypes", + "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" + }, + { + "ImportPath": "github.com/golang/protobuf/ptypes/any", + "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" + }, + { + "ImportPath": "github.com/golang/protobuf/ptypes/duration", + "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" + }, + { + "ImportPath": "github.com/golang/protobuf/ptypes/timestamp", + "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" + }, + { + "ImportPath": "github.com/google/gofuzz", + "Rev": "44d81051d367757e1c7c6a5a86423ece9afcf63c" + }, + { + "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" + }, + { + "ImportPath": "github.com/googleapis/gnostic/compiler", + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" + }, + { + "ImportPath": "github.com/googleapis/gnostic/extensions", + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" + }, + { + "ImportPath": "github.com/hashicorp/golang-lru", + "Rev": "a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4" + }, + { + "ImportPath": "github.com/hashicorp/golang-lru/simplelru", + "Rev": "a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4" + }, + { + "ImportPath": "github.com/howeyc/gopass", + "Rev": "bf9dde6d0d2c004a008c27aaee91170c786f6db8" + }, + { + "ImportPath": "github.com/imdario/mergo", + "Rev": "6633656539c1639d9d78127b7d47c622b5d7b6dc" + }, + { + "ImportPath": "github.com/jonboulle/clockwork", + "Rev": "72f9bd7c4e0c2a40055ab3d0f09654f730cce982" + }, + { + "ImportPath": "github.com/juju/ratelimit", + "Rev": "5b9ff866471762aa2ab2dced63c9fb6f53921342" + }, + { + "ImportPath": "github.com/mailru/easyjson/buffer", + "Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0" + }, + { + "ImportPath": "github.com/mailru/easyjson/jlexer", + "Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0" + }, + { + "ImportPath": "github.com/mailru/easyjson/jwriter", + "Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0" + }, + { + "ImportPath": "github.com/pmezard/go-difflib/difflib", + "Rev": "d8ed2627bdf02c080bf22230dbb337003b7aba2d" + }, + { + "ImportPath": "github.com/spf13/pflag", + "Rev": "9ff6c6923cfffbcd502984b8e0c80539a94968b7" + }, + { + "ImportPath": "github.com/stretchr/testify/assert", + "Rev": "f6abca593680b2315d2075e0f5e2a9751e3f431a" + }, + { + "ImportPath": "github.com/ugorji/go/codec", + "Rev": "ded73eae5db7e7a0ef6f55aace87a2873c5d2b74" + }, + { + "ImportPath": "golang.org/x/crypto/ssh/terminal", + "Rev": "d172538b2cfce0c13cee31e647d0367aa8cd2486" + }, + { + "ImportPath": "golang.org/x/net/context", + "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" + }, + { + "ImportPath": "golang.org/x/net/context/ctxhttp", + "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" + }, + { + "ImportPath": "golang.org/x/net/http2", + "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" + }, + { + "ImportPath": "golang.org/x/net/http2/hpack", + "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" + }, + { + "ImportPath": "golang.org/x/net/idna", + "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" + }, + { + "ImportPath": "golang.org/x/net/lex/httplex", + "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" + }, + { + "ImportPath": "golang.org/x/oauth2", + "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" + }, + { + "ImportPath": "golang.org/x/oauth2/google", + "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" + }, + { + "ImportPath": "golang.org/x/oauth2/internal", + "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" + }, + { + "ImportPath": "golang.org/x/oauth2/jws", + "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" + }, + { + "ImportPath": "golang.org/x/oauth2/jwt", + "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" + }, + { + "ImportPath": "golang.org/x/sys/unix", + "Rev": "7a4fde3fda8ef580a89dbae8138c26041be14299" + }, + { + "ImportPath": "golang.org/x/text/cases", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/internal/tag", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/language", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/runes", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/secure/bidirule", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/secure/precis", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/transform", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/unicode/bidi", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/unicode/norm", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/width", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "gopkg.in/inf.v0", + "Rev": "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4" + }, + { + "ImportPath": "gopkg.in/yaml.v2", + "Rev": "53feefa2559fb8dfa8d81baad31be332c97d6c77" + } + ] } From 10908324c6e5c8da775d8ed40f6904e7747b10ea Mon Sep 17 00:00:00 2001 From: Antoine Pelisse Date: Thu, 27 Jul 2017 21:49:39 -0700 Subject: [PATCH 3/4] c-go: Add dependencies for http-cache Kubernetes-commit: e77d298f83114318fabce9f36546c9f6a7c24938 --- Godeps/Godeps.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index ec202a5d..25134d60 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -154,6 +154,10 @@ "ImportPath": "github.com/golang/protobuf/ptypes/timestamp", "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" }, + { + "ImportPath": "github.com/google/btree", + "Rev": "7d79101e329e5a3adf994758c578dab82b90c017" + }, { "ImportPath": "github.com/google/gofuzz", "Rev": "44d81051d367757e1c7c6a5a86423ece9afcf63c" @@ -170,6 +174,14 @@ "ImportPath": "github.com/googleapis/gnostic/extensions", "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, + { + "ImportPath": "github.com/gregjones/httpcache", + "Rev": "787624de3eb7bd915c329cba748687a3b22666a6" + }, + { + "ImportPath": "github.com/gregjones/httpcache/diskcache", + "Rev": "787624de3eb7bd915c329cba748687a3b22666a6" + }, { "ImportPath": "github.com/hashicorp/golang-lru", "Rev": "a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4" @@ -206,6 +218,10 @@ "ImportPath": "github.com/mailru/easyjson/jwriter", "Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0" }, + { + "ImportPath": "github.com/peterbourgon/diskv", + "Rev": "5dfcb07a075adbaaa4094cddfd160b1e1c77a043" + }, { "ImportPath": "github.com/pmezard/go-difflib/difflib", "Rev": "d8ed2627bdf02c080bf22230dbb337003b7aba2d" From 9f99bf70e2e285e705afa5463a2e8230dba821ae Mon Sep 17 00:00:00 2001 From: Antoine Pelisse Date: Fri, 4 Aug 2017 08:52:49 -0700 Subject: [PATCH 4/4] c-go/transport: Add test for CacheRoundTripper Kubernetes-commit: d6348cc1ff72be719e0830da2c64ef1689499956 --- transport/round_trippers_test.go | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/transport/round_trippers_test.go b/transport/round_trippers_test.go index d5ffc6bd..c1e30c3f 100644 --- a/transport/round_trippers_test.go +++ b/transport/round_trippers_test.go @@ -17,7 +17,11 @@ limitations under the License. package transport import ( + "bytes" + "io/ioutil" "net/http" + "net/url" + "os" "reflect" "strings" "testing" @@ -216,3 +220,60 @@ func TestAuthProxyRoundTripper(t *testing.T) { } } } + +func TestCacheRoundTripper(t *testing.T) { + rt := &testRoundTripper{} + cacheDir, err := ioutil.TempDir("", "cache-rt") + defer os.RemoveAll(cacheDir) + if err != nil { + t.Fatal(err) + } + cache := NewCacheRoundTripper(cacheDir, rt) + + // First call, caches the response + req := &http.Request{ + Method: http.MethodGet, + URL: &url.URL{Host: "localhost"}, + } + rt.Response = &http.Response{ + Header: http.Header{"ETag": []string{`"123456"`}}, + Body: ioutil.NopCloser(bytes.NewReader([]byte("Content"))), + StatusCode: http.StatusOK, + } + resp, err := cache.RoundTrip(req) + if err != nil { + t.Fatal(err) + } + content, err := ioutil.ReadAll(resp.Body) + if err != nil { + t.Fatal(err) + } + if string(content) != "Content" { + t.Errorf(`Expected Body to be "Content", got %q`, string(content)) + } + + // Second call, returns cached response + req = &http.Request{ + Method: http.MethodGet, + URL: &url.URL{Host: "localhost"}, + } + rt.Response = &http.Response{ + StatusCode: http.StatusNotModified, + Body: ioutil.NopCloser(bytes.NewReader([]byte("Other Content"))), + } + + resp, err = cache.RoundTrip(req) + if err != nil { + t.Fatal(err) + } + + // Read body and make sure we have the initial content + content, err = ioutil.ReadAll(resp.Body) + resp.Body.Close() + if err != nil { + t.Fatal(err) + } + if string(content) != "Content" { + t.Errorf("Invalid content read from cache %q", string(content)) + } +}