From d37a8e495ca5bea42dc5d8c4645229cd6039000e Mon Sep 17 00:00:00 2001 From: Kubernetes Publisher Date: Tue, 29 Aug 2017 12:50:53 +0000 Subject: [PATCH 1/2] sync: reset Godeps/Godeps.json --- Godeps/Godeps.json | 968 ++++++++++++++++----------------------------- 1 file changed, 340 insertions(+), 628 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 93f2998a9..25134d604 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,630 +1,342 @@ { - "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/btree", - "Rev": "7d79101e329e5a3adf994758c578dab82b90c017" - }, - { - "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/gregjones/httpcache", - "Rev": "787624de3eb7bd915c329cba748687a3b22666a6" - }, - { - "ImportPath": "github.com/gregjones/httpcache/diskcache", - "Rev": "787624de3eb7bd915c329cba748687a3b22666a6" - }, - { - "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/peterbourgon/diskv", - "Rev": "5dfcb07a075adbaaa4094cddfd160b1e1c77a043" - }, - { - "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": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/errors", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/meta", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/resource", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apimachinery", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/conversion", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/fields", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/labels", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/selection", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/types", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/cache", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/clock", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/diff", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/errors", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/framer", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/intstr", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/json", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/net", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/runtime", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/sets", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/validation", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/wait", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/yaml", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/version", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/watch", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", - "Rev": "8cc513375dee45d0409b6cd3d1bec72cf3ea1be8" - }, - { - "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/btree", + "Rev": "7d79101e329e5a3adf994758c578dab82b90c017" + }, + { + "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/gregjones/httpcache", + "Rev": "787624de3eb7bd915c329cba748687a3b22666a6" + }, + { + "ImportPath": "github.com/gregjones/httpcache/diskcache", + "Rev": "787624de3eb7bd915c329cba748687a3b22666a6" + }, + { + "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/peterbourgon/diskv", + "Rev": "5dfcb07a075adbaaa4094cddfd160b1e1c77a043" + }, + { + "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 eb8ca254db13d9dbf9a8d898dde80b7b6d108aa5 Mon Sep 17 00:00:00 2001 From: zhouhaibing089 Date: Mon, 9 Jan 2017 09:52:46 +0800 Subject: [PATCH 2/2] plugin/pkg/client/auth: add openstack auth provider Kubernetes-commit: a0cebcb559c5c0ab8a2e50b1ee11cc62f9ebb3a8 --- Godeps/Godeps.json | 28 +++ plugin/pkg/client/auth/BUILD | 2 + plugin/pkg/client/auth/openstack/BUILD | 40 +++++ plugin/pkg/client/auth/openstack/openstack.go | 161 ++++++++++++++++++ .../client/auth/openstack/openstack_test.go | 116 +++++++++++++ plugin/pkg/client/auth/plugins.go | 1 + 6 files changed, 348 insertions(+) create mode 100644 plugin/pkg/client/auth/openstack/BUILD create mode 100644 plugin/pkg/client/auth/openstack/openstack.go create mode 100644 plugin/pkg/client/auth/openstack/openstack_test.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 25134d604..328e0a168 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -174,6 +174,34 @@ "ImportPath": "github.com/googleapis/gnostic/extensions", "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, + { + "ImportPath": "github.com/gophercloud/gophercloud", + "Rev": "ed590d9afe113c6107cd60717b196155e6579e78" + }, + { + "ImportPath": "github.com/gophercloud/gophercloud/openstack", + "Rev": "ed590d9afe113c6107cd60717b196155e6579e78" + }, + { + "ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants", + "Rev": "ed590d9afe113c6107cd60717b196155e6579e78" + }, + { + "ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens", + "Rev": "ed590d9afe113c6107cd60717b196155e6579e78" + }, + { + "ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens", + "Rev": "ed590d9afe113c6107cd60717b196155e6579e78" + }, + { + "ImportPath": "github.com/gophercloud/gophercloud/openstack/utils", + "Rev": "ed590d9afe113c6107cd60717b196155e6579e78" + }, + { + "ImportPath": "github.com/gophercloud/gophercloud/pagination", + "Rev": "ed590d9afe113c6107cd60717b196155e6579e78" + }, { "ImportPath": "github.com/gregjones/httpcache", "Rev": "787624de3eb7bd915c329cba748687a3b22666a6" diff --git a/plugin/pkg/client/auth/BUILD b/plugin/pkg/client/auth/BUILD index b0c9df62f..4ced574ba 100644 --- a/plugin/pkg/client/auth/BUILD +++ b/plugin/pkg/client/auth/BUILD @@ -15,6 +15,7 @@ go_library( "//vendor/k8s.io/client-go/plugin/pkg/client/auth/azure:go_default_library", "//vendor/k8s.io/client-go/plugin/pkg/client/auth/gcp:go_default_library", "//vendor/k8s.io/client-go/plugin/pkg/client/auth/oidc:go_default_library", + "//vendor/k8s.io/client-go/plugin/pkg/client/auth/openstack:go_default_library", ], ) @@ -32,6 +33,7 @@ filegroup( "//staging/src/k8s.io/client-go/plugin/pkg/client/auth/azure:all-srcs", "//staging/src/k8s.io/client-go/plugin/pkg/client/auth/gcp:all-srcs", "//staging/src/k8s.io/client-go/plugin/pkg/client/auth/oidc:all-srcs", + "//staging/src/k8s.io/client-go/plugin/pkg/client/auth/openstack:all-srcs", ], tags = ["automanaged"], ) diff --git a/plugin/pkg/client/auth/openstack/BUILD b/plugin/pkg/client/auth/openstack/BUILD new file mode 100644 index 000000000..b7802cc6e --- /dev/null +++ b/plugin/pkg/client/auth/openstack/BUILD @@ -0,0 +1,40 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", + "go_test", +) + +go_test( + name = "go_default_test", + srcs = ["openstack_test.go"], + library = ":go_default_library", + tags = ["automanaged"], +) + +go_library( + name = "go_default_library", + srcs = ["openstack.go"], + tags = ["automanaged"], + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/github.com/gophercloud/gophercloud/openstack:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/plugin/pkg/client/auth/openstack/openstack.go b/plugin/pkg/client/auth/openstack/openstack.go new file mode 100644 index 000000000..9df949131 --- /dev/null +++ b/plugin/pkg/client/auth/openstack/openstack.go @@ -0,0 +1,161 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package openstack + +import ( + "fmt" + "net/http" + "sync" + "time" + + "github.com/golang/glog" + "github.com/gophercloud/gophercloud/openstack" + + restclient "k8s.io/client-go/rest" +) + +func init() { + if err := restclient.RegisterAuthProviderPlugin("openstack", newOpenstackAuthProvider); err != nil { + glog.Fatalf("Failed to register openstack auth plugin: %s", err) + } +} + +// DefaultTTLDuration is the time before a token gets expired. +const DefaultTTLDuration = 10 * time.Minute + +// openstackAuthProvider is an authprovider for openstack. this provider reads +// the environment variables to determine the client identity, and generates a +// token which will be inserted into the request header later. +type openstackAuthProvider struct { + ttl time.Duration + + tokenGetter TokenGetter +} + +// TokenGetter returns a bearer token that can be inserted into request. +type TokenGetter interface { + Token() (string, error) +} + +type tokenGetter struct{} + +// Token creates a token by authenticate with keystone. +func (*tokenGetter) Token() (string, error) { + options, err := openstack.AuthOptionsFromEnv() + if err != nil { + return "", fmt.Errorf("failed to read openstack env vars: %s", err) + } + client, err := openstack.AuthenticatedClient(options) + if err != nil { + return "", fmt.Errorf("authentication failed: %s", err) + } + return client.TokenID, nil +} + +// cachedGetter caches a token until it gets expired, after the expiration, it will +// generate another token and cache it. +type cachedGetter struct { + mutex sync.Mutex + tokenGetter TokenGetter + + token string + born time.Time + ttl time.Duration +} + +// Token returns the current available token, create a new one if expired. +func (c *cachedGetter) Token() (string, error) { + c.mutex.Lock() + defer c.mutex.Unlock() + + var err error + // no token or exceeds the TTL + if c.token == "" || time.Now().Sub(c.born) > c.ttl { + c.token, err = c.tokenGetter.Token() + if err != nil { + return "", fmt.Errorf("failed to get token: %s", err) + } + c.born = time.Now() + } + return c.token, nil +} + +// tokenRoundTripper implements the RoundTripper interface: adding the bearer token +// into the request header. +type tokenRoundTripper struct { + http.RoundTripper + + tokenGetter TokenGetter +} + +// RoundTrip adds the bearer token into the request. +func (t *tokenRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + // if the authorization header already present, use it. + if req.Header.Get("Authorization") != "" { + return t.RoundTripper.RoundTrip(req) + } + + token, err := t.tokenGetter.Token() + if err == nil { + req.Header.Set("Authorization", "Bearer "+token) + } else { + glog.V(4).Infof("failed to get token: %s", err) + } + + return t.RoundTripper.RoundTrip(req) +} + +// newOpenstackAuthProvider creates an auth provider which works with openstack +// environment. +func newOpenstackAuthProvider(clusterAddress string, config map[string]string, persister restclient.AuthProviderConfigPersister) (restclient.AuthProvider, error) { + var ttlDuration time.Duration + var err error + + ttl, found := config["ttl"] + if !found { + ttlDuration = DefaultTTLDuration + // persist to config + config["ttl"] = ttlDuration.String() + if err = persister.Persist(config); err != nil { + return nil, fmt.Errorf("failed to persist config: %s", err) + } + } else { + ttlDuration, err = time.ParseDuration(ttl) + if err != nil { + return nil, fmt.Errorf("failed to parse ttl config: %s", err) + } + } + + // TODO: read/persist client configuration(OS_XXX env vars) in config + + return &openstackAuthProvider{ + ttl: ttlDuration, + tokenGetter: &tokenGetter{}, + }, nil +} + +func (oap *openstackAuthProvider) WrapTransport(rt http.RoundTripper) http.RoundTripper { + return &tokenRoundTripper{ + RoundTripper: rt, + tokenGetter: &cachedGetter{ + tokenGetter: oap.tokenGetter, + ttl: oap.ttl, + }, + } +} + +func (oap *openstackAuthProvider) Login() error { return nil } diff --git a/plugin/pkg/client/auth/openstack/openstack_test.go b/plugin/pkg/client/auth/openstack/openstack_test.go new file mode 100644 index 000000000..411bec70f --- /dev/null +++ b/plugin/pkg/client/auth/openstack/openstack_test.go @@ -0,0 +1,116 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package openstack + +import ( + "math/rand" + "net/http" + "testing" + "time" +) + +// testTokenGetter is a simple random token getter. +type testTokenGetter struct{} + +const LetterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + +func RandStringBytes(n int) string { + b := make([]byte, n) + for i := range b { + b[i] = LetterBytes[rand.Intn(len(LetterBytes))] + } + return string(b) +} + +func (*testTokenGetter) Token() (string, error) { + return RandStringBytes(32), nil +} + +// testRoundTripper is mocked roundtripper which responds with unauthorized when +// there is no authorization header, otherwise returns status ok. +type testRoundTripper struct{} + +func (trt *testRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + authHeader := req.Header.Get("Authorization") + if authHeader == "" || authHeader == "Bearer " { + return &http.Response{ + StatusCode: http.StatusUnauthorized, + }, nil + } + return &http.Response{StatusCode: http.StatusOK}, nil +} + +func TestOpenstackAuthProvider(t *testing.T) { + trt := &tokenRoundTripper{ + RoundTripper: &testRoundTripper{}, + } + + tests := []struct { + name string + ttl time.Duration + interval time.Duration + same bool + }{ + { + name: "normal", + ttl: 2 * time.Second, + interval: 1 * time.Second, + same: true, + }, + { + name: "expire", + ttl: 1 * time.Second, + interval: 2 * time.Second, + same: false, + }, + } + + for _, test := range tests { + trt.tokenGetter = &cachedGetter{ + tokenGetter: &testTokenGetter{}, + ttl: test.ttl, + } + + req, err := http.NewRequest(http.MethodPost, "https://test-api-server.com", nil) + if err != nil { + t.Errorf("failed to new request: %s", err) + } + trt.RoundTrip(req) + header := req.Header.Get("Authorization") + if header == "" { + t.Errorf("expect to see token in header, but is absent") + } + + time.Sleep(test.interval) + + req, err = http.NewRequest(http.MethodPost, "https://test-api-server.com", nil) + if err != nil { + t.Errorf("failed to new request: %s", err) + } + trt.RoundTrip(req) + newHeader := req.Header.Get("Authorization") + if newHeader == "" { + t.Errorf("expect to see token in header, but is absent") + } + + same := newHeader == header + if same != test.same { + t.Errorf("expect to get %t when compare header, but saw %t", test.same, same) + } + } + +} diff --git a/plugin/pkg/client/auth/plugins.go b/plugin/pkg/client/auth/plugins.go index 0328fbd8e..42085d7ae 100644 --- a/plugin/pkg/client/auth/plugins.go +++ b/plugin/pkg/client/auth/plugins.go @@ -21,4 +21,5 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth/azure" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" + _ "k8s.io/client-go/plugin/pkg/client/auth/openstack" )