Skip to content

Commit

Permalink
fix: Fix argo auth token. Fixes #7175 (#7186)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec committed Nov 22, 2021
1 parent 0ea8554 commit e045577
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
15 changes: 9 additions & 6 deletions util/kubeconfig/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,21 @@ func GetBearerToken(in *restclient.Config, explicitKubeConfigPath string) (strin
// This code is not making actual request. We can ignore it.
_ = auth.UpdateTransportConfig(tc)

rt, err := transport.New(tc)
tp, err := transport.New(tc)
if err != nil {
return "", err
}
req := http.Request{Header: map[string][]string{}}

newT := NewUserAgentRoundTripper("dummy", rt)
resp, err := newT.RoundTrip(&req)
req, err := http.NewRequest("GET", in.Host, nil)
if err != nil {
return "", err
}
resp, err := tc.WrapTransport(tp).RoundTrip(req)
if err != nil {
return "", err
}
resp.Body.Close()
if err := resp.Body.Close(); err != nil {
return "", err
}

token := req.Header.Get("Authorization")
return strings.TrimPrefix(token, "Bearer "), nil
Expand Down
17 changes: 0 additions & 17 deletions util/kubeconfig/roundtripper.go

This file was deleted.

0 comments on commit e045577

Please sign in to comment.