Skip to content

Commit

Permalink
Remove discovery RestClient usage
Browse files Browse the repository at this point in the history
  • Loading branch information
creydr committed Sep 29, 2023
1 parent 4d29b8a commit 8f32fe4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/auth/token_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"time"

Expand Down Expand Up @@ -101,17 +102,21 @@ func (c *OIDCTokenHandler) getHTTPClientForKubeAPIServer() (*http.Client, error)
}

func (c *OIDCTokenHandler) getKubernetesOIDCConfiguration(ctx context.Context) (*openIDMetadata, error) {

Check failure on line 104 in pkg/auth/token_handler.go

View workflow job for this annotation

GitHub Actions / style / Golang / Lint

`(*OIDCTokenHandler).getKubernetesOIDCConfiguration` - `ctx` is unused (unparam)
req := c.kubeClient.Discovery().RESTClient().Get().RequestURI("/.well-known/openid-configuration")

res := req.Do(ctx)
if err := res.Error(); err != nil {
return nil, fmt.Errorf("could not execute request: %w", err)
client, err := c.getHTTPClientForKubeAPIServer()
if err != nil {
return nil, fmt.Errorf("could not get HTTP client for API server: %w", err)
}

body, err := res.Raw()
resp, err := client.Get(KubernetesDefaultIssuer + "/.well-known/openid-configuration")
if err != nil {
return nil, fmt.Errorf("could not get response: %w", err)
}
defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("could not read response body: %w", err)
}

openIdConfig := &openIDMetadata{}
if err := json.Unmarshal(body, openIdConfig); err != nil {
Expand Down

0 comments on commit 8f32fe4

Please sign in to comment.