Skip to content

Commit

Permalink
some small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyOHart committed Oct 23, 2024
1 parent f4194cf commit 4a356a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions apps/managedidentity/managedidentity.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func acquireAzureArc(ctx context.Context, client Client, resource string) (base.
return base.AuthResult{}, fmt.Errorf("expected a 401 response, received %d", response.StatusCode)
}

secret, err := client.getAzureArcSecretKey(response, resource, runtime.GOOS)
secret, err := client.getAzureArcSecretKey(response, runtime.GOOS)
if err != nil {
return base.AuthResult{}, err
}
Expand Down Expand Up @@ -446,9 +446,10 @@ func createAzureArcAuthRequest(ctx context.Context, resource string, key string)
}
req.Header.Set(metaHTTPHeaderName, "true")

if condition := key != ""; condition {
if key != "" {
req.Header.Set("Authorization", fmt.Sprintf("Basic %s", key))
}

return req, nil
}

Expand All @@ -468,7 +469,7 @@ func isAzureArcEnvironment(identityEndpoint, imdsEndpoint string, platform strin
return false
}

func (c *Client) getAzureArcSecretKey(response *http.Response, resource string, platform string) (string, error) {
func (c *Client) getAzureArcSecretKey(response *http.Response, platform string) (string, error) {
wwwAuthenticateHeader := response.Header.Get(wwwAuthenticateHeaderName)

if len(wwwAuthenticateHeader) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion apps/managedidentity/managedidentity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ func TestHandleAzureArcResponse(t *testing.T) {
}

client := &Client{}
_, err := client.getAzureArcSecretKey(response, "", tc.platform)
_, err := client.getAzureArcSecretKey(response, tc.platform)

if err == nil || err.Error() != tc.expectedError {
t.Fatalf("expected error: \"%v\"\ngot error: \"%v\"", tc.expectedError, err)
Expand Down

0 comments on commit 4a356a9

Please sign in to comment.