mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-20 18:10:24 +00:00
Code updates for new SDK.
Kubernetes-commit: 29a0c6f56a0839d6abb9b5d1e339ab84cbbe2a83
This commit is contained in:
parent
5538125344
commit
757f27a376
10
Godeps/Godeps.json
generated
10
Godeps/Godeps.json
generated
@ -16,15 +16,19 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/Azure/go-autorest/autorest",
|
"ImportPath": "github.com/Azure/go-autorest/autorest",
|
||||||
"Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca"
|
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/Azure/go-autorest/autorest/adal",
|
||||||
|
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/Azure/go-autorest/autorest/azure",
|
"ImportPath": "github.com/Azure/go-autorest/autorest/azure",
|
||||||
"Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca"
|
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/Azure/go-autorest/autorest/date",
|
"ImportPath": "github.com/Azure/go-autorest/autorest/date",
|
||||||
"Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca"
|
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/PuerkitoBio/purell",
|
"ImportPath": "github.com/PuerkitoBio/purell",
|
||||||
|
@ -13,7 +13,7 @@ go_test(
|
|||||||
srcs = ["azure_test.go"],
|
srcs = ["azure_test.go"],
|
||||||
library = ":go_default_library",
|
library = ":go_default_library",
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = ["//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library"],
|
deps = ["//vendor/github.com/Azure/go-autorest/autorest/adal:go_default_library"],
|
||||||
)
|
)
|
||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
@ -22,6 +22,7 @@ go_library(
|
|||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
|
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
|
||||||
|
"//vendor/github.com/Azure/go-autorest/autorest/adal:go_default_library",
|
||||||
"//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library",
|
"//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library",
|
||||||
"//vendor/github.com/golang/glog:go_default_library",
|
"//vendor/github.com/golang/glog:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/adal"
|
||||||
"github.com/Azure/go-autorest/autorest/azure"
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ func (r *azureRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
type azureToken struct {
|
type azureToken struct {
|
||||||
token azure.Token
|
token adal.Token
|
||||||
clientID string
|
clientID string
|
||||||
tenantID string
|
tenantID string
|
||||||
apiserverID string
|
apiserverID string
|
||||||
@ -234,7 +235,7 @@ func (ts *azureTokenSource) retrieveTokenFromCfg() (*azureToken, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &azureToken{
|
return &azureToken{
|
||||||
token: azure.Token{
|
token: adal.Token{
|
||||||
AccessToken: accessToken,
|
AccessToken: accessToken,
|
||||||
RefreshToken: refreshToken,
|
RefreshToken: refreshToken,
|
||||||
ExpiresIn: expiresIn,
|
ExpiresIn: expiresIn,
|
||||||
@ -268,15 +269,15 @@ func (ts *azureTokenSource) storeTokenInCfg(token *azureToken) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ts *azureTokenSource) refreshToken(token *azureToken) (*azureToken, error) {
|
func (ts *azureTokenSource) refreshToken(token *azureToken) (*azureToken, error) {
|
||||||
oauthConfig, err := azure.PublicCloud.OAuthConfigForTenant(token.tenantID)
|
oauthConfig, err := adal.NewOAuthConfig(azure.PublicCloud.ActiveDirectoryEndpoint, token.tenantID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("building the OAuth configuration for token refresh: %v", err)
|
return nil, fmt.Errorf("building the OAuth configuration for token refresh: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
callback := func(t azure.Token) error {
|
callback := func(t adal.Token) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
spt, err := azure.NewServicePrincipalTokenFromManualToken(
|
spt, err := adal.NewServicePrincipalTokenFromManualToken(
|
||||||
*oauthConfig,
|
*oauthConfig,
|
||||||
token.clientID,
|
token.clientID,
|
||||||
token.apiserverID,
|
token.apiserverID,
|
||||||
@ -324,12 +325,12 @@ func newAzureTokenSourceDeviceCode(environment azure.Environment, clientID strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ts *azureTokenSourceDeviceCode) Token() (*azureToken, error) {
|
func (ts *azureTokenSourceDeviceCode) Token() (*azureToken, error) {
|
||||||
oauthConfig, err := ts.environment.OAuthConfigForTenant(ts.tenantID)
|
oauthConfig, err := adal.NewOAuthConfig(ts.environment.ActiveDirectoryEndpoint, ts.tenantID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("building the OAuth configuration for device code authentication: %v", err)
|
return nil, fmt.Errorf("building the OAuth configuration for device code authentication: %v", err)
|
||||||
}
|
}
|
||||||
client := &autorest.Client{}
|
client := &autorest.Client{}
|
||||||
deviceCode, err := azure.InitiateDeviceAuth(client, *oauthConfig, ts.clientID, ts.apiserverID)
|
deviceCode, err := adal.InitiateDeviceAuth(client, *oauthConfig, ts.clientID, ts.apiserverID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("initialing the device code authentication: %v", err)
|
return nil, fmt.Errorf("initialing the device code authentication: %v", err)
|
||||||
}
|
}
|
||||||
@ -339,7 +340,7 @@ func (ts *azureTokenSourceDeviceCode) Token() (*azureToken, error) {
|
|||||||
return nil, fmt.Errorf("prompting the device code message: %v", err)
|
return nil, fmt.Errorf("prompting the device code message: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
token, err := azure.WaitForUserCompletion(client, deviceCode)
|
token, err := adal.WaitForUserCompletion(client, deviceCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("waiting for device code authentication to complete: %v", err)
|
return nil, fmt.Errorf("waiting for device code authentication to complete: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Azure/go-autorest/autorest/azure"
|
"github.com/Azure/go-autorest/autorest/adal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAzureTokenSource(t *testing.T) {
|
func TestAzureTokenSource(t *testing.T) {
|
||||||
@ -120,8 +120,8 @@ func token2Cfg(token *azureToken) map[string]string {
|
|||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFackeAzureToken(accessToken string, expiresOn string) azure.Token {
|
func newFackeAzureToken(accessToken string, expiresOn string) adal.Token {
|
||||||
return azure.Token{
|
return adal.Token{
|
||||||
AccessToken: accessToken,
|
AccessToken: accessToken,
|
||||||
RefreshToken: "fake",
|
RefreshToken: "fake",
|
||||||
ExpiresIn: "3600",
|
ExpiresIn: "3600",
|
||||||
|
Loading…
Reference in New Issue
Block a user