Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
29a0c6f5
Commit
29a0c6f5
authored
Jun 09, 2017
by
Brendan Burns
Committed by
Brendan Burns
Jul 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code updates for new SDK.
parent
0d26b36c
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
166 additions
and
88 deletions
+166
-88
BUILD
pkg/cloudprovider/providers/azure/BUILD
+1
-0
azure.go
pkg/cloudprovider/providers/azure/azure.go
+14
-13
azure_backoff.go
pkg/cloudprovider/providers/azure/azure_backoff.go
+37
-17
azure_blob.go
pkg/cloudprovider/providers/azure/azure_blob.go
+20
-5
azure_file.go
pkg/cloudprovider/providers/azure/azure_file.go
+10
-5
azure_loadbalancer.go
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
+32
-17
azure_routes.go
pkg/cloudprovider/providers/azure/azure_routes.go
+12
-5
azure_storage.go
pkg/cloudprovider/providers/azure/azure_storage.go
+8
-4
azure_test.go
pkg/cloudprovider/providers/azure/azure_test.go
+2
-2
azure_util.go
pkg/cloudprovider/providers/azure/azure_util.go
+2
-2
BUILD
pkg/credentialprovider/azure/BUILD
+2
-0
azure_credentials.go
pkg/credentialprovider/azure/azure_credentials.go
+5
-3
Godeps.json
staging/src/k8s.io/client-go/Godeps/Godeps.json
+7
-3
BUILD
...g/src/k8s.io/client-go/plugin/pkg/client/auth/azure/BUILD
+2
-1
azure.go
...rc/k8s.io/client-go/plugin/pkg/client/auth/azure/azure.go
+9
-8
azure_test.go
...s.io/client-go/plugin/pkg/client/auth/azure/azure_test.go
+3
-3
No files found.
pkg/cloudprovider/providers/azure/BUILD
View file @
29a0c6f5
...
...
@@ -37,6 +37,7 @@ go_library(
"//vendor/github.com/Azure/azure-sdk-for-go/arm/storage:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/storage: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/to:go_default_library",
"//vendor/github.com/ghodss/yaml:go_default_library",
...
...
pkg/cloudprovider/providers/azure/azure.go
View file @
29a0c6f5
...
...
@@ -33,6 +33,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/azure-sdk-for-go/arm/storage"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/ghodss/yaml"
"github.com/golang/glog"
...
...
@@ -142,14 +143,14 @@ func decodePkcs12(pkcs []byte, password string) (*x509.Certificate, *rsa.Private
}
// newServicePrincipalToken creates a new service principal token based on the configuration
func
newServicePrincipalToken
(
az
*
Cloud
)
(
*
a
zure
.
ServicePrincipalToken
,
error
)
{
oauthConfig
,
err
:=
a
z
.
Environment
.
OAuthConfigForTenant
(
az
.
TenantID
)
func
newServicePrincipalToken
(
az
*
Cloud
)
(
*
a
dal
.
ServicePrincipalToken
,
error
)
{
oauthConfig
,
err
:=
a
dal
.
NewOAuthConfig
(
az
.
Environment
.
ActiveDirectoryEndpoint
,
az
.
TenantID
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"creating the OAuth config: %v"
,
err
)
}
if
len
(
az
.
AADClientSecret
)
>
0
{
return
a
zure
.
NewServicePrincipalToken
(
return
a
dal
.
NewServicePrincipalToken
(
*
oauthConfig
,
az
.
AADClientID
,
az
.
AADClientSecret
,
...
...
@@ -163,7 +164,7 @@ func newServicePrincipalToken(az *Cloud) (*azure.ServicePrincipalToken, error) {
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"decoding the client certificate: %v"
,
err
)
}
return
a
zure
.
NewServicePrincipalTokenFromCertificate
(
return
a
dal
.
NewServicePrincipalTokenFromCertificate
(
*
oauthConfig
,
az
.
AADClientID
,
certificate
,
...
...
@@ -203,54 +204,54 @@ func NewCloud(configReader io.Reader) (cloudprovider.Interface, error) {
az
.
SubnetsClient
=
network
.
NewSubnetsClient
(
az
.
SubscriptionID
)
az
.
SubnetsClient
.
BaseURI
=
az
.
Environment
.
ResourceManagerEndpoint
az
.
SubnetsClient
.
Authorizer
=
servicePrincipalToken
az
.
SubnetsClient
.
Authorizer
=
autorest
.
NewBearerAuthorizer
(
servicePrincipalToken
)
az
.
SubnetsClient
.
PollingDelay
=
5
*
time
.
Second
configureUserAgent
(
&
az
.
SubnetsClient
.
Client
)
az
.
RouteTablesClient
=
network
.
NewRouteTablesClient
(
az
.
SubscriptionID
)
az
.
RouteTablesClient
.
BaseURI
=
az
.
Environment
.
ResourceManagerEndpoint
az
.
RouteTablesClient
.
Authorizer
=
servicePrincipalToken
az
.
RouteTablesClient
.
Authorizer
=
autorest
.
NewBearerAuthorizer
(
servicePrincipalToken
)
az
.
RouteTablesClient
.
PollingDelay
=
5
*
time
.
Second
configureUserAgent
(
&
az
.
RouteTablesClient
.
Client
)
az
.
RoutesClient
=
network
.
NewRoutesClient
(
az
.
SubscriptionID
)
az
.
RoutesClient
.
BaseURI
=
az
.
Environment
.
ResourceManagerEndpoint
az
.
RoutesClient
.
Authorizer
=
servicePrincipalToken
az
.
RoutesClient
.
Authorizer
=
autorest
.
NewBearerAuthorizer
(
servicePrincipalToken
)
az
.
RoutesClient
.
PollingDelay
=
5
*
time
.
Second
configureUserAgent
(
&
az
.
RoutesClient
.
Client
)
az
.
InterfacesClient
=
network
.
NewInterfacesClient
(
az
.
SubscriptionID
)
az
.
InterfacesClient
.
BaseURI
=
az
.
Environment
.
ResourceManagerEndpoint
az
.
InterfacesClient
.
Authorizer
=
servicePrincipalToken
az
.
InterfacesClient
.
Authorizer
=
autorest
.
NewBearerAuthorizer
(
servicePrincipalToken
)
az
.
InterfacesClient
.
PollingDelay
=
5
*
time
.
Second
configureUserAgent
(
&
az
.
InterfacesClient
.
Client
)
az
.
LoadBalancerClient
=
network
.
NewLoadBalancersClient
(
az
.
SubscriptionID
)
az
.
LoadBalancerClient
.
BaseURI
=
az
.
Environment
.
ResourceManagerEndpoint
az
.
LoadBalancerClient
.
Authorizer
=
servicePrincipalToken
az
.
LoadBalancerClient
.
Authorizer
=
autorest
.
NewBearerAuthorizer
(
servicePrincipalToken
)
az
.
LoadBalancerClient
.
PollingDelay
=
5
*
time
.
Second
configureUserAgent
(
&
az
.
LoadBalancerClient
.
Client
)
az
.
VirtualMachinesClient
=
compute
.
NewVirtualMachinesClient
(
az
.
SubscriptionID
)
az
.
VirtualMachinesClient
.
BaseURI
=
az
.
Environment
.
ResourceManagerEndpoint
az
.
VirtualMachinesClient
.
Authorizer
=
servicePrincipalToken
az
.
VirtualMachinesClient
.
Authorizer
=
autorest
.
NewBearerAuthorizer
(
servicePrincipalToken
)
az
.
VirtualMachinesClient
.
PollingDelay
=
5
*
time
.
Second
configureUserAgent
(
&
az
.
VirtualMachinesClient
.
Client
)
az
.
PublicIPAddressesClient
=
network
.
NewPublicIPAddressesClient
(
az
.
SubscriptionID
)
az
.
PublicIPAddressesClient
.
BaseURI
=
az
.
Environment
.
ResourceManagerEndpoint
az
.
PublicIPAddressesClient
.
Authorizer
=
servicePrincipalToken
az
.
PublicIPAddressesClient
.
Authorizer
=
autorest
.
NewBearerAuthorizer
(
servicePrincipalToken
)
az
.
PublicIPAddressesClient
.
PollingDelay
=
5
*
time
.
Second
configureUserAgent
(
&
az
.
PublicIPAddressesClient
.
Client
)
az
.
SecurityGroupsClient
=
network
.
NewSecurityGroupsClient
(
az
.
SubscriptionID
)
az
.
SecurityGroupsClient
.
BaseURI
=
az
.
Environment
.
ResourceManagerEndpoint
az
.
SecurityGroupsClient
.
Authorizer
=
servicePrincipalToken
az
.
SecurityGroupsClient
.
Authorizer
=
autorest
.
NewBearerAuthorizer
(
servicePrincipalToken
)
az
.
SecurityGroupsClient
.
PollingDelay
=
5
*
time
.
Second
configureUserAgent
(
&
az
.
SecurityGroupsClient
.
Client
)
az
.
StorageAccountClient
=
storage
.
NewAccountsClientWithBaseURI
(
az
.
Environment
.
ResourceManagerEndpoint
,
az
.
SubscriptionID
)
az
.
StorageAccountClient
.
Authorizer
=
servicePrincipalToken
az
.
StorageAccountClient
.
Authorizer
=
autorest
.
NewBearerAuthorizer
(
servicePrincipalToken
)
// Conditionally configure rate limits
if
az
.
CloudProviderRateLimit
{
...
...
pkg/cloudprovider/providers/azure/azure_backoff.go
View file @
29a0c6f5
...
...
@@ -47,8 +47,10 @@ func (az *Cloud) GetVirtualMachineWithRetry(name types.NodeName) (compute.Virtua
func
(
az
*
Cloud
)
CreateOrUpdateSGWithRetry
(
sg
network
.
SecurityGroup
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
resourceRequestBackoff
,
func
()
(
bool
,
error
)
{
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
SecurityGroupsClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
sg
.
Name
,
sg
,
nil
)
return
processRetryResponse
(
resp
,
err
)
respChan
,
errChan
:=
az
.
SecurityGroupsClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
sg
.
Name
,
sg
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
.
Response
,
err
)
})
}
...
...
@@ -56,8 +58,10 @@ func (az *Cloud) CreateOrUpdateSGWithRetry(sg network.SecurityGroup) error {
func
(
az
*
Cloud
)
CreateOrUpdateLBWithRetry
(
lb
network
.
LoadBalancer
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
resourceRequestBackoff
,
func
()
(
bool
,
error
)
{
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
LoadBalancerClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
lb
.
Name
,
lb
,
nil
)
return
processRetryResponse
(
resp
,
err
)
respChan
,
errChan
:=
az
.
LoadBalancerClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
lb
.
Name
,
lb
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
.
Response
,
err
)
})
}
...
...
@@ -65,8 +69,10 @@ func (az *Cloud) CreateOrUpdateLBWithRetry(lb network.LoadBalancer) error {
func
(
az
*
Cloud
)
CreateOrUpdatePIPWithRetry
(
pip
network
.
PublicIPAddress
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
resourceRequestBackoff
,
func
()
(
bool
,
error
)
{
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
PublicIPAddressesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
pip
.
Name
,
pip
,
nil
)
return
processRetryResponse
(
resp
,
err
)
respChan
,
errChan
:=
az
.
PublicIPAddressesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
pip
.
Name
,
pip
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
.
Response
,
err
)
})
}
...
...
@@ -74,8 +80,10 @@ func (az *Cloud) CreateOrUpdatePIPWithRetry(pip network.PublicIPAddress) error {
func
(
az
*
Cloud
)
CreateOrUpdateInterfaceWithRetry
(
nic
network
.
Interface
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
resourceRequestBackoff
,
func
()
(
bool
,
error
)
{
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
InterfacesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
nic
.
Name
,
nic
,
nil
)
return
processRetryResponse
(
resp
,
err
)
respChan
,
errChan
:=
az
.
InterfacesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
nic
.
Name
,
nic
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
.
Response
,
err
)
})
}
...
...
@@ -83,7 +91,9 @@ func (az *Cloud) CreateOrUpdateInterfaceWithRetry(nic network.Interface) error {
func
(
az
*
Cloud
)
DeletePublicIPWithRetry
(
pipName
string
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
resourceRequestBackoff
,
func
()
(
bool
,
error
)
{
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
PublicIPAddressesClient
.
Delete
(
az
.
ResourceGroup
,
pipName
,
nil
)
respChan
,
errChan
:=
az
.
PublicIPAddressesClient
.
Delete
(
az
.
ResourceGroup
,
pipName
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
,
err
)
})
}
...
...
@@ -92,7 +102,9 @@ func (az *Cloud) DeletePublicIPWithRetry(pipName string) error {
func
(
az
*
Cloud
)
DeleteLBWithRetry
(
lbName
string
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
resourceRequestBackoff
,
func
()
(
bool
,
error
)
{
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
LoadBalancerClient
.
Delete
(
az
.
ResourceGroup
,
lbName
,
nil
)
respChan
,
errChan
:=
az
.
LoadBalancerClient
.
Delete
(
az
.
ResourceGroup
,
lbName
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
,
err
)
})
}
...
...
@@ -101,8 +113,10 @@ func (az *Cloud) DeleteLBWithRetry(lbName string) error {
func
(
az
*
Cloud
)
CreateOrUpdateRouteTableWithRetry
(
routeTable
network
.
RouteTable
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
resourceRequestBackoff
,
func
()
(
bool
,
error
)
{
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
RouteTablesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeTable
,
nil
)
return
processRetryResponse
(
resp
,
err
)
respChan
,
errChan
:=
az
.
RouteTablesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeTable
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
.
Response
,
err
)
})
}
...
...
@@ -110,8 +124,10 @@ func (az *Cloud) CreateOrUpdateRouteTableWithRetry(routeTable network.RouteTable
func
(
az
*
Cloud
)
CreateOrUpdateRouteWithRetry
(
route
network
.
Route
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
resourceRequestBackoff
,
func
()
(
bool
,
error
)
{
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
RoutesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
*
route
.
Name
,
route
,
nil
)
return
processRetryResponse
(
resp
,
err
)
respChan
,
errChan
:=
az
.
RoutesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
*
route
.
Name
,
route
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
.
Response
,
err
)
})
}
...
...
@@ -119,7 +135,9 @@ func (az *Cloud) CreateOrUpdateRouteWithRetry(route network.Route) error {
func
(
az
*
Cloud
)
DeleteRouteWithRetry
(
routeName
string
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
resourceRequestBackoff
,
func
()
(
bool
,
error
)
{
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
RoutesClient
.
Delete
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeName
,
nil
)
respChan
,
errChan
:=
az
.
RoutesClient
.
Delete
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeName
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
,
err
)
})
}
...
...
@@ -128,8 +146,10 @@ func (az *Cloud) DeleteRouteWithRetry(routeName string) error {
func
(
az
*
Cloud
)
CreateOrUpdateVMWithRetry
(
vmName
string
,
newVM
compute
.
VirtualMachine
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
resourceRequestBackoff
,
func
()
(
bool
,
error
)
{
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
vmName
,
newVM
,
nil
)
return
processRetryResponse
(
resp
,
err
)
respChan
,
errChan
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
vmName
,
newVM
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
.
Response
,
err
)
})
}
...
...
pkg/cloudprovider/providers/azure/azure_blob.go
View file @
29a0c6f5
...
...
@@ -21,6 +21,8 @@ import (
"regexp"
"strings"
"bytes"
azs
"github.com/Azure/azure-sdk-for-go/storage"
)
...
...
@@ -40,14 +42,21 @@ func (az *Cloud) createVhdBlob(accountName, accountKey, name string, sizeGB int6
vhdSize
:=
size
+
vhdHeaderSize
/* header size */
// Blob name in URL must end with '.vhd' extension.
name
=
name
+
".vhd"
err
=
blobClient
.
PutPageBlob
(
vhdContainerName
,
name
,
vhdSize
,
tags
)
cnt
:=
blobClient
.
GetContainerReference
(
vhdContainerName
)
b
:=
cnt
.
GetBlobReference
(
name
)
b
.
Properties
.
ContentLength
=
vhdSize
b
.
Metadata
=
tags
err
=
b
.
PutPageBlob
(
nil
)
if
err
!=
nil
{
// if container doesn't exist, create one and retry PutPageBlob
detail
:=
err
.
Error
()
if
strings
.
Contains
(
detail
,
errContainerNotFound
)
{
err
=
blobClient
.
CreateContainer
(
vhdContainerName
,
azs
.
ContainerAccessTypePrivate
)
err
=
cnt
.
Create
(
&
azs
.
CreateContainerOptions
{
Access
:
azs
.
ContainerAccessTypePrivate
}
)
if
err
==
nil
{
err
=
blobClient
.
PutPageBlob
(
vhdContainerName
,
name
,
vhdSize
,
tags
)
b
:=
cnt
.
GetBlobReference
(
name
)
b
.
Properties
.
ContentLength
=
vhdSize
b
.
Metadata
=
tags
err
=
b
.
PutPageBlob
(
nil
)
}
}
}
...
...
@@ -61,7 +70,11 @@ func (az *Cloud) createVhdBlob(accountName, accountKey, name string, sizeGB int6
az
.
deleteVhdBlob
(
accountName
,
accountKey
,
name
)
return
""
,
""
,
fmt
.
Errorf
(
"failed to create vhd header, err: %v"
,
err
)
}
if
err
=
blobClient
.
PutPage
(
vhdContainerName
,
name
,
size
,
vhdSize
-
1
,
azs
.
PageWriteTypeUpdate
,
h
[
:
vhdHeaderSize
],
nil
);
err
!=
nil
{
blobRange
:=
azs
.
BlobRange
{
Start
:
uint64
(
size
),
End
:
uint64
(
vhdSize
-
1
),
}
if
err
=
b
.
WriteRange
(
blobRange
,
bytes
.
NewBuffer
(
h
[
:
vhdHeaderSize
]),
nil
);
err
!=
nil
{
az
.
deleteVhdBlob
(
accountName
,
accountKey
,
name
)
return
""
,
""
,
fmt
.
Errorf
(
"failed to update vhd header, err: %v"
,
err
)
}
...
...
@@ -80,7 +93,9 @@ func (az *Cloud) createVhdBlob(accountName, accountKey, name string, sizeGB int6
func
(
az
*
Cloud
)
deleteVhdBlob
(
accountName
,
accountKey
,
blobName
string
)
error
{
blobClient
,
err
:=
az
.
getBlobClient
(
accountName
,
accountKey
)
if
err
==
nil
{
return
blobClient
.
DeleteBlob
(
vhdContainerName
,
blobName
,
nil
)
cnt
:=
blobClient
.
GetContainerReference
(
vhdContainerName
)
b
:=
cnt
.
GetBlobReference
(
blobName
)
return
b
.
Delete
(
nil
)
}
return
err
}
...
...
pkg/cloudprovider/providers/azure/azure_file.go
View file @
29a0c6f5
...
...
@@ -18,9 +18,9 @@ package azure
import
(
"fmt"
"strconv"
azs
"github.com/Azure/azure-sdk-for-go/storage"
"github.com/golang/glog"
)
// create file share
...
...
@@ -34,11 +34,15 @@ func (az *Cloud) createFileShare(accountName, accountKey, name string, sizeGB in
// setting x-ms-share-quota can set quota on the new share, but in reality, setting quota in CreateShare
// receives error "The metadata specified is invalid. It has characters that are not permitted."
// As a result,breaking into two API calls: create share and set quota
if
err
=
fileClient
.
CreateShare
(
name
,
nil
);
err
!=
nil
{
share
:=
fileClient
.
GetShareReference
(
name
)
if
err
=
share
.
Create
(
nil
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to create file share, err: %v"
,
err
)
}
if
err
=
fileClient
.
SetShareProperties
(
name
,
azs
.
ShareHeaders
{
Quota
:
strconv
.
Itoa
(
sizeGB
)});
err
!=
nil
{
az
.
deleteFileShare
(
accountName
,
accountKey
,
name
)
share
.
Properties
.
Quota
=
sizeGB
if
err
=
share
.
SetProperties
(
nil
);
err
!=
nil
{
if
err
:=
share
.
Delete
(
nil
);
err
!=
nil
{
glog
.
Errorf
(
"Error deleting share: %v"
,
err
)
}
return
fmt
.
Errorf
(
"failed to set quota on file share %s, err: %v"
,
name
,
err
)
}
return
nil
...
...
@@ -48,7 +52,8 @@ func (az *Cloud) createFileShare(accountName, accountKey, name string, sizeGB in
func
(
az
*
Cloud
)
deleteFileShare
(
accountName
,
accountKey
,
name
string
)
error
{
fileClient
,
err
:=
az
.
getFileSvcClient
(
accountName
,
accountKey
)
if
err
==
nil
{
return
fileClient
.
DeleteShare
(
name
)
share
:=
fileClient
.
GetShareReference
(
name
)
return
share
.
Delete
(
nil
)
}
return
err
}
...
...
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
View file @
29a0c6f5
...
...
@@ -143,8 +143,10 @@ func (az *Cloud) EnsureLoadBalancer(clusterName string, service *v1.Service, nod
sg
.
SecurityGroupPropertiesFormat
.
NetworkInterfaces
=
nil
sg
.
SecurityGroupPropertiesFormat
.
Subnets
=
nil
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
SecurityGroupsClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
sg
.
Name
,
sg
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
respChan
,
errChan
:=
az
.
SecurityGroupsClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
sg
.
Name
,
sg
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
.
Response
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"ensure(%s) backing off: sg(%s) - updating"
,
serviceName
,
*
sg
.
Name
)
retryErr
:=
az
.
CreateOrUpdateSGWithRetry
(
sg
)
if
retryErr
!=
nil
{
...
...
@@ -222,8 +224,10 @@ func (az *Cloud) EnsureLoadBalancer(clusterName string, service *v1.Service, nod
if
!
existsLb
||
lbNeedsUpdate
{
glog
.
V
(
3
)
.
Infof
(
"ensure(%s): lb(%s) - updating"
,
serviceName
,
lbName
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
LoadBalancerClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
lb
.
Name
,
lb
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
respChan
,
errChan
:=
az
.
LoadBalancerClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
lb
.
Name
,
lb
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
.
Response
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"ensure(%s) backing off: lb(%s) - updating"
,
serviceName
,
lbName
)
retryErr
:=
az
.
CreateOrUpdateLBWithRetry
(
lb
)
if
retryErr
!=
nil
{
...
...
@@ -315,8 +319,10 @@ func (az *Cloud) EnsureLoadBalancerDeleted(clusterName string, service *v1.Servi
sg
.
SecurityGroupPropertiesFormat
.
NetworkInterfaces
=
nil
sg
.
SecurityGroupPropertiesFormat
.
Subnets
=
nil
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
SecurityGroupsClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
reconciledSg
.
Name
,
reconciledSg
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
respChan
,
errChan
:=
az
.
SecurityGroupsClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
reconciledSg
.
Name
,
reconciledSg
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
.
Response
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"delete(%s) backing off: sg(%s) - updating"
,
serviceName
,
az
.
SecurityGroupName
)
retryErr
:=
az
.
CreateOrUpdateSGWithRetry
(
reconciledSg
)
if
retryErr
!=
nil
{
...
...
@@ -369,8 +375,10 @@ func (az *Cloud) cleanupLoadBalancer(clusterName string, service *v1.Service, is
if
len
(
*
lb
.
FrontendIPConfigurations
)
>
0
{
glog
.
V
(
3
)
.
Infof
(
"delete(%s): lb(%s) - updating"
,
serviceName
,
lbName
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
LoadBalancerClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
lb
.
Name
,
lb
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
respChan
,
errChan
:=
az
.
LoadBalancerClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
lb
.
Name
,
lb
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
.
Response
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"delete(%s) backing off: sg(%s) - updating"
,
serviceName
,
az
.
SecurityGroupName
)
retryErr
:=
az
.
CreateOrUpdateLBWithRetry
(
lb
)
if
retryErr
!=
nil
{
...
...
@@ -385,7 +393,9 @@ func (az *Cloud) cleanupLoadBalancer(clusterName string, service *v1.Service, is
glog
.
V
(
3
)
.
Infof
(
"delete(%s): lb(%s) - deleting; no remaining frontendipconfigs"
,
serviceName
,
lbName
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
LoadBalancerClient
.
Delete
(
az
.
ResourceGroup
,
lbName
,
nil
)
respChan
,
errChan
:=
az
.
LoadBalancerClient
.
Delete
(
az
.
ResourceGroup
,
lbName
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"delete(%s) backing off: lb(%s) - deleting; no remaining frontendipconfigs"
,
serviceName
,
lbName
)
retryErr
:=
az
.
DeleteLBWithRetry
(
lbName
)
...
...
@@ -440,8 +450,10 @@ func (az *Cloud) ensurePublicIPExists(serviceName, pipName string) (*network.Pub
glog
.
V
(
3
)
.
Infof
(
"ensure(%s): pip(%s) - creating"
,
serviceName
,
*
pip
.
Name
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
PublicIPAddressesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
pip
.
Name
,
pip
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
respChan
,
errChan
:=
az
.
PublicIPAddressesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
pip
.
Name
,
pip
,
nil
)
resp
:=
<-
respChan
err
=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
.
Response
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"ensure(%s) backing off: pip(%s) - creating"
,
serviceName
,
*
pip
.
Name
)
retryErr
:=
az
.
CreateOrUpdatePIPWithRetry
(
pip
)
if
retryErr
!=
nil
{
...
...
@@ -466,8 +478,9 @@ func (az *Cloud) ensurePublicIPExists(serviceName, pipName string) (*network.Pub
func
(
az
*
Cloud
)
ensurePublicIPDeleted
(
serviceName
,
pipName
string
)
error
{
glog
.
V
(
2
)
.
Infof
(
"ensure(%s): pip(%s) - deleting"
,
serviceName
,
pipName
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
deleteErr
:=
az
.
PublicIPAddressesClient
.
Delete
(
az
.
ResourceGroup
,
pipName
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
deleteErr
)
{
resp
,
deleteErrChan
:=
az
.
PublicIPAddressesClient
.
Delete
(
az
.
ResourceGroup
,
pipName
,
nil
)
deleteErr
:=
<-
deleteErrChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
<-
resp
,
deleteErr
)
{
glog
.
V
(
2
)
.
Infof
(
"ensure(%s) backing off: pip(%s) - deleting"
,
serviceName
,
pipName
)
retryErr
:=
az
.
DeletePublicIPWithRetry
(
pipName
)
if
retryErr
!=
nil
{
...
...
@@ -772,8 +785,8 @@ func (az *Cloud) reconcileSecurityGroup(sg network.SecurityGroup, clusterName st
DestinationPortRange
:
to
.
StringPtr
(
strconv
.
Itoa
(
int
(
port
.
Port
))),
SourceAddressPrefix
:
to
.
StringPtr
(
sourceAddressPrefixes
[
j
]),
DestinationAddressPrefix
:
to
.
StringPtr
(
"*"
),
Access
:
network
.
Allow
,
Direction
:
network
.
Inbound
,
Access
:
network
.
SecurityRuleAccess
Allow
,
Direction
:
network
.
SecurityRuleDirection
Inbound
,
},
}
}
...
...
@@ -918,8 +931,10 @@ func (az *Cloud) ensureHostInPool(serviceName string, nodeName types.NodeName, b
glog
.
V
(
3
)
.
Infof
(
"nicupdate(%s): nic(%s) - updating"
,
serviceName
,
nicName
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
InterfacesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
nic
.
Name
,
nic
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
respChan
,
errChan
:=
az
.
InterfacesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
nic
.
Name
,
nic
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
.
Response
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"nicupdate(%s) backing off: nic(%s) - updating, err=%v"
,
serviceName
,
nicName
,
err
)
retryErr
:=
az
.
CreateOrUpdateInterfaceWithRetry
(
nic
)
if
retryErr
!=
nil
{
...
...
pkg/cloudprovider/providers/azure/azure_routes.go
View file @
29a0c6f5
...
...
@@ -78,8 +78,10 @@ func (az *Cloud) CreateRoute(clusterName string, nameHint string, kubeRoute *clo
glog
.
V
(
3
)
.
Infof
(
"create: creating routetable. routeTableName=%q"
,
az
.
RouteTableName
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
RouteTablesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeTable
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
respChan
,
errChan
:=
az
.
RouteTablesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeTable
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
.
Response
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"create backing off: creating routetable. routeTableName=%q"
,
az
.
RouteTableName
)
retryErr
:=
az
.
CreateOrUpdateRouteTableWithRetry
(
routeTable
)
if
retryErr
!=
nil
{
...
...
@@ -114,8 +116,10 @@ func (az *Cloud) CreateRoute(clusterName string, nameHint string, kubeRoute *clo
glog
.
V
(
3
)
.
Infof
(
"create: creating route: instance=%q cidr=%q"
,
kubeRoute
.
TargetNode
,
kubeRoute
.
DestinationCIDR
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
RoutesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
*
route
.
Name
,
route
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
respChan
,
errChan
:=
az
.
RoutesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
*
route
.
Name
,
route
,
nil
)
resp
:=
<-
respChan
err
=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
.
Response
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"create backing off: creating route: instance=%q cidr=%q"
,
kubeRoute
.
TargetNode
,
kubeRoute
.
DestinationCIDR
)
retryErr
:=
az
.
CreateOrUpdateRouteWithRetry
(
route
)
if
retryErr
!=
nil
{
...
...
@@ -138,7 +142,10 @@ func (az *Cloud) DeleteRoute(clusterName string, kubeRoute *cloudprovider.Route)
routeName
:=
mapNodeNameToRouteName
(
kubeRoute
.
TargetNode
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
RoutesClient
.
Delete
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeName
,
nil
)
respChan
,
errChan
:=
az
.
RoutesClient
.
Delete
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeName
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"delete backing off: deleting route. clusterName=%q instance=%q cidr=%q"
,
clusterName
,
kubeRoute
.
TargetNode
,
kubeRoute
.
DestinationCIDR
)
retryErr
:=
az
.
DeleteRouteWithRetry
(
routeName
)
...
...
pkg/cloudprovider/providers/azure/azure_storage.go
View file @
29a0c6f5
...
...
@@ -66,8 +66,10 @@ func (az *Cloud) AttachDisk(diskName, diskURI string, nodeName types.NodeName, l
vmName
:=
mapNodeNameToVMName
(
nodeName
)
glog
.
V
(
2
)
.
Infof
(
"create(%s): vm(%s)"
,
az
.
ResourceGroup
,
vmName
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
vmName
,
newVM
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
respChan
,
errChan
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
vmName
,
newVM
,
nil
)
resp
:=
<-
respChan
err
=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
.
Response
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"create(%s) backing off: vm(%s)"
,
az
.
ResourceGroup
,
vmName
)
retryErr
:=
az
.
CreateOrUpdateVMWithRetry
(
vmName
,
newVM
)
if
retryErr
!=
nil
{
...
...
@@ -147,8 +149,10 @@ func (az *Cloud) DetachDiskByName(diskName, diskURI string, nodeName types.NodeN
vmName
:=
mapNodeNameToVMName
(
nodeName
)
glog
.
V
(
2
)
.
Infof
(
"create(%s): vm(%s)"
,
az
.
ResourceGroup
,
vmName
)
az
.
operationPollRateLimiter
.
Accept
()
resp
,
err
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
vmName
,
newVM
,
nil
)
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
,
err
)
{
respChan
,
errChan
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
vmName
,
newVM
,
nil
)
resp
:=
<-
respChan
err
=
<-
errChan
if
az
.
CloudProviderBackoff
&&
shouldRetryAPIRequest
(
resp
.
Response
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"create(%s) backing off: vm(%s)"
,
az
.
ResourceGroup
,
vmName
)
retryErr
:=
az
.
CreateOrUpdateVMWithRetry
(
vmName
,
newVM
)
if
retryErr
!=
nil
{
...
...
pkg/cloudprovider/providers/azure/azure_test.go
View file @
29a0c6f5
...
...
@@ -556,7 +556,7 @@ func TestProtocolTranslationTCP(t *testing.T) {
if
*
transportProto
!=
network
.
TransportProtocolTCP
{
t
.
Errorf
(
"Expected TCP LoadBalancer Rule Protocol. Got %v"
,
transportProto
)
}
if
*
securityGroupProto
!=
network
.
TCP
{
if
*
securityGroupProto
!=
network
.
SecurityRuleProtocol
TCP
{
t
.
Errorf
(
"Expected TCP SecurityGroup Protocol. Got %v"
,
transportProto
)
}
if
*
probeProto
!=
network
.
ProbeProtocolTCP
{
...
...
@@ -570,7 +570,7 @@ func TestProtocolTranslationUDP(t *testing.T) {
if
*
transportProto
!=
network
.
TransportProtocolUDP
{
t
.
Errorf
(
"Expected UDP LoadBalancer Rule Protocol. Got %v"
,
transportProto
)
}
if
*
securityGroupProto
!=
network
.
UDP
{
if
*
securityGroupProto
!=
network
.
SecurityRuleProtocol
UDP
{
t
.
Errorf
(
"Expected UDP SecurityGroup Protocol. Got %v"
,
transportProto
)
}
if
probeProto
!=
nil
{
...
...
pkg/cloudprovider/providers/azure/azure_util.go
View file @
29a0c6f5
...
...
@@ -135,12 +135,12 @@ func getProtocolsFromKubernetesProtocol(protocol v1.Protocol) (*network.Transpor
switch
protocol
{
case
v1
.
ProtocolTCP
:
transportProto
=
network
.
TransportProtocolTCP
securityProto
=
network
.
TCP
securityProto
=
network
.
SecurityRuleProtocol
TCP
probeProto
=
network
.
ProbeProtocolTCP
return
&
transportProto
,
&
securityProto
,
&
probeProto
,
nil
case
v1
.
ProtocolUDP
:
transportProto
=
network
.
TransportProtocolUDP
securityProto
=
network
.
UDP
securityProto
=
network
.
SecurityRuleProtocol
UDP
return
&
transportProto
,
&
securityProto
,
nil
,
nil
default
:
return
&
transportProto
,
&
securityProto
,
&
probeProto
,
fmt
.
Errorf
(
"Only TCP and UDP are supported for Azure LoadBalancers"
)
...
...
pkg/credentialprovider/azure/BUILD
View file @
29a0c6f5
...
...
@@ -16,6 +16,8 @@ go_library(
"//pkg/cloudprovider/providers/azure:go_default_library",
"//pkg/credentialprovider:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry: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/golang/glog:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
...
...
pkg/credentialprovider/azure/azure_credentials.go
View file @
29a0c6f5
...
...
@@ -23,6 +23,8 @@ import (
yaml
"gopkg.in/yaml.v2"
"github.com/Azure/azure-sdk-for-go/arm/containerregistry"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
azureapi
"github.com/Azure/go-autorest/autorest/azure"
"github.com/golang/glog"
"github.com/spf13/pflag"
...
...
@@ -94,13 +96,13 @@ func (a *acrProvider) Enabled() bool {
return
false
}
oauthConfig
,
err
:=
a
.
environment
.
OAuthConfigForTenant
(
a
.
config
.
TenantID
)
oauthConfig
,
err
:=
a
dal
.
NewOAuthConfig
(
a
.
environment
.
ActiveDirectoryEndpoint
,
a
.
config
.
TenantID
)
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to get oauth config: %v"
,
err
)
return
false
}
servicePrincipalToken
,
err
:=
a
zureapi
.
NewServicePrincipalToken
(
servicePrincipalToken
,
err
:=
a
dal
.
NewServicePrincipalToken
(
*
oauthConfig
,
a
.
config
.
AADClientID
,
a
.
config
.
AADClientSecret
,
...
...
@@ -112,7 +114,7 @@ func (a *acrProvider) Enabled() bool {
registryClient
:=
containerregistry
.
NewRegistriesClient
(
a
.
config
.
SubscriptionID
)
registryClient
.
BaseURI
=
a
.
environment
.
ResourceManagerEndpoint
registryClient
.
Authorizer
=
servicePrincipalToken
registryClient
.
Authorizer
=
autorest
.
NewBearerAuthorizer
(
servicePrincipalToken
)
a
.
registryClient
=
registryClient
return
true
...
...
staging/src/k8s.io/client-go/Godeps/Godeps.json
View file @
29a0c6f5
...
...
@@ -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"
,
...
...
staging/src/k8s.io/client-go/plugin/pkg/client/auth/azure/BUILD
View file @
29a0c6f5
...
...
@@ -13,7 +13,7 @@ go_test(
srcs = ["azure_test.go"],
library = ":go_default_library",
tags = ["automanaged"],
deps = ["//vendor/github.com/Azure/go-autorest/autorest/a
zure
:go_default_library"],
deps = ["//vendor/github.com/Azure/go-autorest/autorest/a
dal
: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",
...
...
staging/src/k8s.io/client-go/plugin/pkg/client/auth/azure/azure.go
View file @
29a0c6f5
...
...
@@ -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
a
zure
.
Token
token
a
dal
.
Token
clientID
string
tenantID
string
apiserverID
string
...
...
@@ -234,7 +235,7 @@ func (ts *azureTokenSource) retrieveTokenFromCfg() (*azureToken, error) {
}
return
&
azureToken
{
token
:
a
zure
.
Token
{
token
:
a
dal
.
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
:=
a
zure
.
PublicCloud
.
OAuthConfigForTenant
(
token
.
tenantID
)
oauthConfig
,
err
:=
a
dal
.
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
a
zure
.
Token
)
error
{
callback
:=
func
(
t
a
dal
.
Token
)
error
{
return
nil
}
spt
,
err
:=
a
zure
.
NewServicePrincipalTokenFromManualToken
(
spt
,
err
:=
a
dal
.
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
:=
a
zure
.
InitiateDeviceAuth
(
client
,
*
oauthConfig
,
ts
.
clientID
,
ts
.
apiserverID
)
deviceCode
,
err
:=
a
dal
.
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
:=
a
zure
.
WaitForUserCompletion
(
client
,
deviceCode
)
token
,
err
:=
a
dal
.
WaitForUserCompletion
(
client
,
deviceCode
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"waiting for device code authentication to complete: %v"
,
err
)
}
...
...
staging/src/k8s.io/client-go/plugin/pkg/client/auth/azure/azure_test.go
View file @
29a0c6f5
...
...
@@ -23,7 +23,7 @@ import (
"testing"
"time"
"github.com/Azure/go-autorest/autorest/a
zure
"
"github.com/Azure/go-autorest/autorest/a
dal
"
)
func
TestAzureTokenSource
(
t
*
testing
.
T
)
{
...
...
@@ -120,8 +120,8 @@ func token2Cfg(token *azureToken) map[string]string {
return
cfg
}
func
newFackeAzureToken
(
accessToken
string
,
expiresOn
string
)
a
zure
.
Token
{
return
a
zure
.
Token
{
func
newFackeAzureToken
(
accessToken
string
,
expiresOn
string
)
a
dal
.
Token
{
return
a
dal
.
Token
{
AccessToken
:
accessToken
,
RefreshToken
:
"fake"
,
ExpiresIn
:
"3600"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment