client-go: Update RoundTrippers to be Unwrappable

Kubernetes-commit: fd5775c192fb4d47250a2d99f3e022acb1c7c0f0
This commit is contained in:
Antoine Pelisse
2017-08-16 08:39:57 -07:00
committed by Kubernetes Publisher
parent db8228460e
commit fc47db2e7e
8 changed files with 24 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ import (
"github.com/golang/glog"
"github.com/gophercloud/gophercloud/openstack"
"k8s.io/apimachinery/pkg/util/net"
restclient "k8s.io/client-go/rest"
)
@@ -102,6 +103,8 @@ type tokenRoundTripper struct {
tokenGetter TokenGetter
}
var _ net.RoundTripperWrapper = &tokenRoundTripper{}
// 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.
@@ -119,6 +122,8 @@ func (t *tokenRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
return t.RoundTripper.RoundTrip(req)
}
func (t *tokenRoundTripper) WrappedRoundTripper() http.RoundTripper { return t.RoundTripper }
// newOpenstackAuthProvider creates an auth provider which works with openstack
// environment.
func newOpenstackAuthProvider(clusterAddress string, config map[string]string, persister restclient.AuthProviderConfigPersister) (restclient.AuthProvider, error) {