mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-29 21:29:24 +00:00
added a e2e test that uses the staged client; made necessary changes to gcp auth plugin to pass the gke tests
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/google"
|
||||
|
||||
clientreporestclient "k8s.io/client-go/1.4/rest"
|
||||
"k8s.io/kubernetes/pkg/client/restclient"
|
||||
)
|
||||
|
||||
@@ -32,6 +33,9 @@ func init() {
|
||||
if err := restclient.RegisterAuthProviderPlugin("gcp", newGCPAuthProvider); err != nil {
|
||||
glog.Fatalf("Failed to register gcp auth plugin: %v", err)
|
||||
}
|
||||
if err := clientreporestclient.RegisterAuthProviderPlugin("gcp", newGCPAuthProviderForClientRepo); err != nil {
|
||||
glog.Fatalf("Failed to register gcp auth plugin: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
type gcpAuthProvider struct {
|
||||
@@ -47,6 +51,15 @@ func newGCPAuthProvider(_ string, gcpConfig map[string]string, persister restcli
|
||||
return &gcpAuthProvider{ts, persister}, nil
|
||||
}
|
||||
|
||||
// newGCPAuthProviderForClientRepo is the same as newGCPAuthProvider, but is programmed against client-go's interface
|
||||
func newGCPAuthProviderForClientRepo(_ string, gcpConfig map[string]string, persister clientreporestclient.AuthProviderConfigPersister) (clientreporestclient.AuthProvider, error) {
|
||||
ts, err := newCachedTokenSource(gcpConfig["access-token"], gcpConfig["expiry"], persister)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &gcpAuthProvider{ts, persister}, nil
|
||||
}
|
||||
|
||||
func (g *gcpAuthProvider) WrapTransport(rt http.RoundTripper) http.RoundTripper {
|
||||
return &oauth2.Transport{
|
||||
Source: g.tokenSource,
|
||||
|
||||
Reference in New Issue
Block a user