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 44 "context"
55 "encoding/json"
66 "fmt"
7+ "net/http"
78 "strconv"
89 "time"
910
@@ -165,17 +166,20 @@ func NewExperimentManager(configData json.RawMessage) (manager.CustomExperimentM
165166 if err != nil {
166167 return nil , fmt .Errorf ("failed to create XP experiment manager: %s" , err )
167168 }
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
173177 }
174- googleClient . Timeout = defaultRequestTimeout
178+
175179 // Create XP client
176180 client , err := xpclient .NewClientWithResponses (
177181 config .BaseURL ,
178- xpclient .WithHTTPClient (googleClient ),
182+ xpclient .WithHTTPClient (httpClient ),
179183 )
180184 if err != nil {
181185 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(
566566) (* LocalStorage , error ) {
567567 // Set up Request Modifiers
568568 clientOptions := []managementClient.ClientOption {}
569+ httpClient := http .DefaultClient
569570 if authzEnabled {
570- var googleClient * http.Client
571571 var err error
572572 // Init Google client for Authz. When using a non-empty googleApplicationCredentialsEnvVar that contains a file
573573 // path to a credentials file, the credentials file MUST contain a Google SERVICE ACCOUNT for authentication to
574574 // work correctly
575575 if filepath := os .Getenv (googleApplicationCredentialsEnvVar ); filepath != "" {
576- googleClient , err = auth .InitGoogleClientFromCredentialsFile (context .Background (), filepath )
576+ httpClient , err = auth .InitGoogleClientFromCredentialsFile (context .Background (), filepath )
577577 } else {
578- googleClient , err = auth .InitGoogleClient (context .Background ())
578+ httpClient , err = auth .InitGoogleClient (context .Background ())
579579 }
580580 if err != nil {
581581 return nil , err
582582 }
583-
584- clientOptions = append (
585- clientOptions ,
586- managementClient .WithHTTPClient (googleClient ),
587- )
588583 }
584+ clientOptions = append (
585+ clientOptions ,
586+ managementClient .WithHTTPClient (httpClient ),
587+ )
589588 xpClient , err := managementClient .NewClientWithResponses (xpServer , clientOptions ... )
590589 if err != nil {
591590 return nil , err
You can’t perform that action at this time.
0 commit comments