File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed
Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,17 @@ func (c *AzureDevopsClient) SetAccessToken(token string) {
149149 c .accessToken = & token
150150}
151151
152+ func (c * AzureDevopsClient ) UseAzAuth () error {
153+ opts := azidentity.DefaultAzureCredentialOptions {}
154+ cred , err := azidentity .NewDefaultAzureCredential (& opts )
155+ if err != nil {
156+ return err
157+ }
158+
159+ c .azcreds = cred
160+ return nil
161+ }
162+
152163func (c * AzureDevopsClient ) SupportsPatAuthentication () bool {
153164 return c .accessToken != nil && len (* c .accessToken ) > 0
154165}
@@ -181,16 +192,6 @@ func (c *AzureDevopsClient) restWithAuthentication(domain string) (*resty.Client
181192 if c .SupportsPatAuthentication () {
182193 c .restClient .SetBasicAuth ("" , * c .accessToken )
183194 } else {
184- if c .azcreds == nil {
185- opts := azidentity.DefaultAzureCredentialOptions {}
186- cred , err := azidentity .NewDefaultAzureCredential (& opts )
187- if err != nil {
188- panic (err )
189- }
190-
191- c .azcreds = cred
192- }
193-
194195 ctx := context .Background ()
195196 opts := policy.TokenRequestOptions {
196197 Scopes : []string {AZURE_DEVOPS_SCOPE },
Original file line number Diff line number Diff line change @@ -179,6 +179,10 @@ func initAzureDevOpsConnection() {
179179 AzureDevopsClient .SetOrganization (opts .AzureDevops .Organisation )
180180 if opts .AzureDevops .AccessToken != "" {
181181 AzureDevopsClient .SetAccessToken (opts .AzureDevops .AccessToken )
182+ } else {
183+ if err := AzureDevopsClient .UseAzAuth (); err != nil {
184+ logger .Fatalf (err .Error ())
185+ }
182186 }
183187 AzureDevopsClient .SetApiVersion (opts .AzureDevops .ApiVersion )
184188 AzureDevopsClient .SetConcurrency (opts .Request .ConcurrencyLimit )
You can’t perform that action at this time.
0 commit comments