@@ -21,6 +21,8 @@ import (
2121
2222// AzClient is an interface for client to Azure
2323type AzClient interface {
24+ SetAuthorizer (authorizer autorest.Authorizer )
25+
2426 GetGateway () (n.ApplicationGateway , error )
2527 UpdateGateway (* n.ApplicationGateway ) error
2628 DeployGatewayWithVnet (ResourceGroup , ResourceName , ResourceName , string ) error
@@ -36,7 +38,6 @@ type azClient struct {
3638 subnetsClient n.SubnetsClient
3739 groupsClient r.GroupsClient
3840 deploymentsClient r.DeploymentsClient
39- authorizer autorest.Authorizer
4041
4142 subscriptionID SubscriptionID
4243 resourceGroupName ResourceGroup
@@ -47,7 +48,7 @@ type azClient struct {
4748}
4849
4950// NewAzClient returns an Azure Client
50- func NewAzClient (subscriptionID SubscriptionID , resourceGroupName ResourceGroup , appGwName ResourceName , authorizer autorest. Authorizer ) AzClient {
51+ func NewAzClient (subscriptionID SubscriptionID , resourceGroupName ResourceGroup , appGwName ResourceName ) AzClient {
5152 settings , err := auth .GetSettingsFromEnvironment ()
5253 if err != nil {
5354 return nil
@@ -67,43 +68,40 @@ func NewAzClient(subscriptionID SubscriptionID, resourceGroupName ResourceGroup,
6768 appGwName : appGwName ,
6869 memoizedIPs : make (map [string ]n.PublicIPAddress ),
6970
70- ctx : context .Background (),
71- authorizer : authorizer ,
71+ ctx : context .Background (),
7272 }
7373
7474 if err := az .appGatewaysClient .AddToUserAgent (userAgent ); err != nil {
7575 glog .Error ("Error adding User Agent to App Gateway client: " , userAgent )
7676 }
77- az .appGatewaysClient .Authorizer = az .authorizer
78-
7977 if err := az .publicIPsClient .AddToUserAgent (userAgent ); err != nil {
8078 glog .Error ("Error adding User Agent to Public IP client: " , userAgent )
8179 }
82- az .publicIPsClient .Authorizer = az .authorizer
83-
8480 if err := az .virtualNetworksClient .AddToUserAgent (userAgent ); err != nil {
8581 glog .Error ("Error adding User Agent to Virtual Networks client: " , userAgent )
8682 }
87- az .virtualNetworksClient .Authorizer = az .authorizer
88-
8983 if err := az .subnetsClient .AddToUserAgent (userAgent ); err != nil {
9084 glog .Error ("Error adding User Agent to Subnets client: " , userAgent )
9185 }
92- az .subnetsClient .Authorizer = az .authorizer
93-
9486 if err := az .groupsClient .AddToUserAgent (userAgent ); err != nil {
9587 glog .Error ("Error adding User Agent to Groups client: " , userAgent )
9688 }
97- az .groupsClient .Authorizer = az .authorizer
98-
9989 if err := az .deploymentsClient .AddToUserAgent (userAgent ); err != nil {
10090 glog .Error ("Error adding User Agent to Deployments client: " , userAgent )
10191 }
102- az .deploymentsClient .Authorizer = az .authorizer
10392
10493 return az
10594}
10695
96+ func (az * azClient ) SetAuthorizer (authorizer autorest.Authorizer ) {
97+ az .appGatewaysClient .Authorizer = authorizer
98+ az .publicIPsClient .Authorizer = authorizer
99+ az .virtualNetworksClient .Authorizer = authorizer
100+ az .subnetsClient .Authorizer = authorizer
101+ az .groupsClient .Authorizer = authorizer
102+ az .deploymentsClient .Authorizer = authorizer
103+ }
104+
107105func (az * azClient ) GetGateway () (n.ApplicationGateway , error ) {
108106 return az .appGatewaysClient .Get (az .ctx , string (az .resourceGroupName ), string (az .appGwName ))
109107}
0 commit comments