From 4a356a9fea4591b6c201c7b8196a35a8dde873ac Mon Sep 17 00:00:00 2001 From: Andrew O Hart Date: Wed, 23 Oct 2024 11:00:47 +0100 Subject: [PATCH] some small fixes --- apps/managedidentity/managedidentity.go | 7 ++++--- apps/managedidentity/managedidentity_test.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/managedidentity/managedidentity.go b/apps/managedidentity/managedidentity.go index ce5dd151..c3afc20f 100644 --- a/apps/managedidentity/managedidentity.go +++ b/apps/managedidentity/managedidentity.go @@ -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 } @@ -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 } @@ -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 { diff --git a/apps/managedidentity/managedidentity_test.go b/apps/managedidentity/managedidentity_test.go index e126d5c9..fbe4dc2d 100644 --- a/apps/managedidentity/managedidentity_test.go +++ b/apps/managedidentity/managedidentity_test.go @@ -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)