File tree Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Original file line number Diff line number Diff line change 4
4
"context"
5
5
"encoding/json"
6
6
"fmt"
7
+ "net/http"
7
8
"strconv"
8
9
"time"
9
10
@@ -165,17 +166,20 @@ func NewExperimentManager(configData json.RawMessage) (manager.CustomExperimentM
165
166
if err != nil {
166
167
return nil , fmt .Errorf ("failed to create XP experiment manager: %s" , err )
167
168
}
168
-
169
- // Create Google Client
170
- googleClient , err := auth .InitGoogleClient (context .Background ())
171
- if err != nil {
172
- return nil , err
169
+ httpClient := http .DefaultClient
170
+ if config .TreatmentServicePluginConfig .ManagementService .AuthorizationEnabled {
171
+ // Create Google Client
172
+ httpClient , err = auth .InitGoogleClient (context .Background ())
173
+ if err != nil {
174
+ return nil , err
175
+ }
176
+ httpClient .Timeout = defaultRequestTimeout
173
177
}
174
- googleClient . Timeout = defaultRequestTimeout
178
+
175
179
// Create XP client
176
180
client , err := xpclient .NewClientWithResponses (
177
181
config .BaseURL ,
178
- xpclient .WithHTTPClient (googleClient ),
182
+ xpclient .WithHTTPClient (httpClient ),
179
183
)
180
184
if err != nil {
181
185
return nil , fmt .Errorf ("Unable to create XP management client: %s" , err .Error ())
Original file line number Diff line number Diff line change @@ -566,26 +566,25 @@ func NewLocalStorage(
566
566
) (* LocalStorage , error ) {
567
567
// Set up Request Modifiers
568
568
clientOptions := []managementClient.ClientOption {}
569
+ httpClient := http .DefaultClient
569
570
if authzEnabled {
570
- var googleClient * http.Client
571
571
var err error
572
572
// Init Google client for Authz. When using a non-empty googleApplicationCredentialsEnvVar that contains a file
573
573
// path to a credentials file, the credentials file MUST contain a Google SERVICE ACCOUNT for authentication to
574
574
// work correctly
575
575
if filepath := os .Getenv (googleApplicationCredentialsEnvVar ); filepath != "" {
576
- googleClient , err = auth .InitGoogleClientFromCredentialsFile (context .Background (), filepath )
576
+ httpClient , err = auth .InitGoogleClientFromCredentialsFile (context .Background (), filepath )
577
577
} else {
578
- googleClient , err = auth .InitGoogleClient (context .Background ())
578
+ httpClient , err = auth .InitGoogleClient (context .Background ())
579
579
}
580
580
if err != nil {
581
581
return nil , err
582
582
}
583
-
584
- clientOptions = append (
585
- clientOptions ,
586
- managementClient .WithHTTPClient (googleClient ),
587
- )
588
583
}
584
+ clientOptions = append (
585
+ clientOptions ,
586
+ managementClient .WithHTTPClient (httpClient ),
587
+ )
589
588
xpClient , err := managementClient .NewClientWithResponses (xpServer , clientOptions ... )
590
589
if err != nil {
591
590
return nil , err
You can’t perform that action at this time.
0 commit comments