Code updates for new SDK.

Kubernetes-commit: 29a0c6f56a0839d6abb9b5d1e339ab84cbbe2a83
This commit is contained in:
Brendan Burns 2017-06-09 05:20:01 +00:00 committed by Kubernetes Publisher
parent 5538125344
commit 757f27a376
4 changed files with 21 additions and 15 deletions

10
Godeps/Godeps.json generated
View File

@ -16,15 +16,19 @@
},
{
"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",
"Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca"
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
},
{
"ImportPath": "github.com/Azure/go-autorest/autorest/date",
"Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca"
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
},
{
"ImportPath": "github.com/PuerkitoBio/purell",

View File

@ -13,7 +13,7 @@ go_test(
srcs = ["azure_test.go"],
library = ":go_default_library",
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(
@ -22,6 +22,7 @@ go_library(
tags = ["automanaged"],
deps = [
"//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/golang/glog:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",

View File

@ -24,6 +24,7 @@ import (
"sync"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/golang/glog"
@ -137,7 +138,7 @@ func (r *azureRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
}
type azureToken struct {
token azure.Token
token adal.Token
clientID string
tenantID string
apiserverID string
@ -234,7 +235,7 @@ func (ts *azureTokenSource) retrieveTokenFromCfg() (*azureToken, error) {
}
return &azureToken{
token: azure.Token{
token: adal.Token{
AccessToken: accessToken,
RefreshToken: refreshToken,
ExpiresIn: expiresIn,
@ -268,15 +269,15 @@ func (ts *azureTokenSource) storeTokenInCfg(token *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 {
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
}
spt, err := azure.NewServicePrincipalTokenFromManualToken(
spt, err := adal.NewServicePrincipalTokenFromManualToken(
*oauthConfig,
token.clientID,
token.apiserverID,
@ -324,12 +325,12 @@ func newAzureTokenSourceDeviceCode(environment azure.Environment, clientID strin
}
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 {
return nil, fmt.Errorf("building the OAuth configuration for device code authentication: %v", err)
}
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 {
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)
}
token, err := azure.WaitForUserCompletion(client, deviceCode)
token, err := adal.WaitForUserCompletion(client, deviceCode)
if err != nil {
return nil, fmt.Errorf("waiting for device code authentication to complete: %v", err)
}

View File

@ -23,7 +23,7 @@ import (
"testing"
"time"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/adal"
)
func TestAzureTokenSource(t *testing.T) {
@ -120,8 +120,8 @@ func token2Cfg(token *azureToken) map[string]string {
return cfg
}
func newFackeAzureToken(accessToken string, expiresOn string) azure.Token {
return azure.Token{
func newFackeAzureToken(accessToken string, expiresOn string) adal.Token {
return adal.Token{
AccessToken: accessToken,
RefreshToken: "fake",
ExpiresIn: "3600",