@@ -259,15 +259,15 @@ func (client Client) AcquireToken(ctx context.Context, resource string, options
259259
260260 switch client .source {
261261 case AzureArc :
262- return acquireAzureArc (ctx , client , resource )
262+ return acquireTokenForAzureArc (ctx , client , resource )
263263 case DefaultToIMDS :
264- return acquireIMDS (ctx , client , resource )
264+ return acquireTokenForIMDS (ctx , client , resource )
265265 default :
266266 return base.AuthResult {}, fmt .Errorf ("unsupported source %q" , client .source )
267267 }
268268}
269269
270- func acquireIMDS (ctx context.Context , client Client , resource string ) (base.AuthResult , error ) {
270+ func acquireTokenForIMDS (ctx context.Context , client Client , resource string ) (base.AuthResult , error ) {
271271 req , err := createIMDSAuthRequest (ctx , client .miType , resource )
272272 if err != nil {
273273 return base.AuthResult {}, err
@@ -280,7 +280,7 @@ func acquireIMDS(ctx context.Context, client Client, resource string) (base.Auth
280280 return authResultFromToken (client .authParams , tokenResponse )
281281}
282282
283- func acquireAzureArc (ctx context.Context , client Client , resource string ) (base.AuthResult , error ) {
283+ func acquireTokenForAzureArc (ctx context.Context , client Client , resource string ) (base.AuthResult , error ) {
284284 req , err := createAzureArcAuthRequest (ctx , resource , "" )
285285 if err != nil {
286286 return base.AuthResult {}, err
@@ -314,13 +314,13 @@ func acquireAzureArc(ctx context.Context, client Client, resource string) (base.
314314
315315 responseBytes , err := io .ReadAll (secondResponse .Body )
316316 if err != nil {
317- return base.AuthResult {}, fmt .Errorf ("failed to read second azure arc response body: %w " , err )
317+ return base.AuthResult {}, fmt .Errorf ("failed to read second azure arc response body: %s " , err )
318318 }
319319
320320 var r accesstokens.TokenResponse
321321 err = json .Unmarshal (responseBytes , & r )
322322 if err != nil {
323- return base.AuthResult {}, fmt .Errorf ("failed to unmarshal second response body: %w " , err )
323+ return base.AuthResult {}, fmt .Errorf ("failed to unmarshal second response body: %s " , err )
324324 }
325325
326326 r .GrantedScopes .Slice = append (r .GrantedScopes .Slice , secondRequest .URL .Query ().Get (resourceQueryParameterName ))
@@ -479,7 +479,7 @@ func (c *Client) getAzureArcSecretKey(response *http.Response, platform string)
479479 // check if the platform is supported
480480 expectedSecretFilePath := getAzureArcPlatformPath (platform )
481481 if expectedSecretFilePath == "" {
482- return "" , fmt . Errorf ("platform not supported, expected linux or windows, got %s" , platform )
482+ return "" , errors . New ("platform not supported, expected linux or windows" )
483483 }
484484
485485 parts := strings .Split (wwwAuthenticateHeader , "Basic realm=" )
@@ -505,11 +505,9 @@ func (c *Client) getAzureArcSecretKey(response *http.Response, platform string)
505505 return "" , fmt .Errorf ("failed to get metadata for %s due to error: %s" , secretFilePath [1 ], err )
506506 }
507507
508- secretFileSize := fileInfo .Size ()
509-
510508 // Throw an error if the secret file's size is greater than 4096 bytes
511509 if s := fileInfo .Size (); s > azureArcMaxFileSizeBytes {
512- return "" , fmt .Errorf ("invalid secret file size, expected %d, file size was %d" , azureArcMaxFileSizeBytes , secretFileSize )
510+ return "" , fmt .Errorf ("invalid secret file size, expected %d, file size was %d" , azureArcMaxFileSizeBytes , s )
513511 }
514512
515513 // Attempt to read the contents of the secret file
0 commit comments