Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyOHart committed Oct 22, 2024
1 parent 523d218 commit f4194cf
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions apps/managedidentity/managedidentity.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ func (client Client) AcquireToken(ctx context.Context, resource string, options

switch client.source {
case AzureArc:
return acquireAzureArc(ctx, client, resource, client.authParams)
return acquireAzureArc(ctx, client, resource)
case DefaultToIMDS:
return acquireIMDS(ctx, client, resource, client.authParams)
return acquireIMDS(ctx, client, resource)
default:
return base.AuthResult{}, fmt.Errorf("unsupported source %q", client.source)
}
}

func acquireIMDS(ctx context.Context, client Client, resource string, fakeAuthParams authority.AuthParams) (base.AuthResult, error) {
func acquireIMDS(ctx context.Context, client Client, resource string) (base.AuthResult, error) {
req, err := createIMDSAuthRequest(ctx, client.miType, resource)
if err != nil {
return base.AuthResult{}, err
Expand All @@ -277,10 +277,10 @@ func acquireIMDS(ctx context.Context, client Client, resource string, fakeAuthPa
if err != nil {
return base.AuthResult{}, err
}
return authResultFromToken(fakeAuthParams, tokenResponse)
return authResultFromToken(client.authParams, tokenResponse)
}

func acquireAzureArc(ctx context.Context, client Client, resource string, fakeAuthParams authority.AuthParams) (base.AuthResult, error) {
func acquireAzureArc(ctx context.Context, client Client, resource string) (base.AuthResult, error) {
req, err := createAzureArcAuthRequest(ctx, resource, "")
if err != nil {
return base.AuthResult{}, err
Expand Down Expand Up @@ -312,10 +312,6 @@ func acquireAzureArc(ctx context.Context, client Client, resource string, fakeAu
}
defer secondResponse.Body.Close()

if err != nil {
return base.AuthResult{}, err
}

responseBytes, err := io.ReadAll(secondResponse.Body)
if err != nil {
return base.AuthResult{}, fmt.Errorf("failed to read second azure arc response body: %w", err)
Expand Down

0 comments on commit f4194cf

Please sign in to comment.