Skip to content

Commit

Permalink
Merge pull request #1450 from MartinForReal/release-1.1-backport
Browse files Browse the repository at this point in the history
[release-1.1] Backport Private link service client to release 1.1
  • Loading branch information
k8s-ci-robot committed Apr 12, 2022
2 parents a090c94 + 5702374 commit 5f24a20
Show file tree
Hide file tree
Showing 27 changed files with 1,158 additions and 233 deletions.
33 changes: 25 additions & 8 deletions pkg/azureclients/armclient/azure_armclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
"time"
"unicode"

"sigs.k8s.io/cloud-provider-azure/pkg/azureclients"

"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"

Expand Down Expand Up @@ -75,20 +77,35 @@ type Client struct {
}

// New creates a ARM client
func New(authorizer autorest.Authorizer, baseURI, userAgent, apiVersion, clientRegion string, clientBackoff *retry.Backoff) *Client {
restClient := autorest.NewClientWithUserAgent(userAgent)
restClient.PollingDelay = 5 * time.Second
restClient.RetryAttempts = 3
restClient.RetryDuration = time.Second * 1
func New(authorizer autorest.Authorizer, clientConfig azureclients.ClientConfig, baseURI, apiVersion string) *Client {
restClient := autorest.NewClientWithUserAgent(clientConfig.UserAgent)
restClient.Authorizer = authorizer
restClient.Sender = getSender()
restClient.Sender = autorest.DecorateSender(restClient.Sender, autorest.DoCloseIfError())

if userAgent == "" {
if clientConfig.UserAgent == "" {
restClient.UserAgent = GetUserAgent(restClient)
}

backoff := clientBackoff
if clientConfig.RestClientConfig.PollingDelay == nil {
restClient.PollingDelay = 5 * time.Second
} else {
restClient.PollingDelay = *clientConfig.RestClientConfig.PollingDelay
}

if clientConfig.RestClientConfig.RetryAttempts == nil {
restClient.RetryAttempts = 3
} else {
restClient.RetryAttempts = *clientConfig.RestClientConfig.RetryAttempts
}

if clientConfig.RestClientConfig.RetryDuration == nil {
restClient.RetryDuration = 1 * time.Second
} else {
restClient.RetryDuration = *clientConfig.RestClientConfig.RetryDuration
}

backoff := clientConfig.Backoff
if backoff == nil {
backoff = &retry.Backoff{}
}
Expand All @@ -102,7 +119,7 @@ func New(authorizer autorest.Authorizer, baseURI, userAgent, apiVersion, clientR
baseURI: baseURI,
backoff: backoff,
apiVersion: apiVersion,
clientRegion: NormalizeAzureRegion(clientRegion),
clientRegion: NormalizeAzureRegion(clientConfig.Location),
}
}

Expand Down

0 comments on commit 5f24a20

Please sign in to comment.