@@ -160,7 +160,8 @@ func (c *AzureDevopsClient) SupportsPatAuthentication() bool {
160160}
161161
162162func (c * AzureDevopsClient ) rest () * resty.Client {
163- var client , err = c .restWithAuthentication ("dev.azure.com" )
163+
164+ var client , err = c .restWithAuthentication (& c .restClient , "dev.azure.com" )
164165
165166 if err != nil {
166167 c .logger .Fatalf ("could not create a rest client: %v" , err )
@@ -170,7 +171,8 @@ func (c *AzureDevopsClient) rest() *resty.Client {
170171}
171172
172173func (c * AzureDevopsClient ) restVsrm () * resty.Client {
173- var client , err = c .restWithAuthentication ("vsrm.dev.azure.com" )
174+
175+ var client , err = c .restWithAuthentication (& c .restClientVsrm , "vsrm.dev.azure.com" )
174176
175177 if err != nil {
176178 c .logger .Fatalf ("could not create a rest client: %v" , err )
@@ -179,13 +181,14 @@ func (c *AzureDevopsClient) restVsrm() *resty.Client {
179181 return client
180182}
181183
182- func (c * AzureDevopsClient ) restWithAuthentication (domain string ) (* resty.Client , error ) {
183- if c .restClient == nil {
184- c .restClient = c .restWithoutToken (domain )
184+ func (c * AzureDevopsClient ) restWithAuthentication (restClient * * resty.Client , domain string ) (* resty.Client , error ) {
185+
186+ if * restClient == nil {
187+ * restClient = c .restWithoutToken (domain )
185188 }
186189
187190 if c .SupportsPatAuthentication () {
188- c . restClient .SetBasicAuth ("" , * c .accessToken )
191+ ( * restClient ) .SetBasicAuth ("" , * c .accessToken )
189192 } else {
190193 ctx := context .Background ()
191194 opts := policy.TokenRequestOptions {
@@ -196,10 +199,10 @@ func (c *AzureDevopsClient) restWithAuthentication(domain string) (*resty.Client
196199 panic (err )
197200 }
198201
199- c . restClient .SetBasicAuth ("" , accessToken .Token )
202+ ( * restClient ) .SetBasicAuth ("" , accessToken .Token )
200203 }
201204
202- return c . restClient , nil
205+ return ( * restClient ) , nil
203206}
204207
205208func (c * AzureDevopsClient ) restWithoutToken (domain string ) * resty.Client {
0 commit comments