@@ -10,6 +10,7 @@ import (
10
10
authenticationapi "github.com/openshift/origin/pkg/auth/api"
11
11
authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization"
12
12
"github.com/openshift/origin/pkg/client"
13
+ utilnet "k8s.io/apimachinery/pkg/util/net"
13
14
)
14
15
15
16
type impersonatingRoundTripper struct {
@@ -23,7 +24,7 @@ func NewImpersonatingRoundTripper(user user.Info, delegate http.RoundTripper) ht
23
24
}
24
25
25
26
func (rt * impersonatingRoundTripper ) RoundTrip (req * http.Request ) (* http.Response , error ) {
26
- req = cloneRequest (req )
27
+ req = utilnet . CloneRequest (req )
27
28
req .Header .Del (authenticationapi .ImpersonateUserHeader )
28
29
req .Header .Del (authenticationapi .ImpersonateGroupHeader )
29
30
req .Header .Del (authenticationapi .ImpersonateUserScopeHeader )
@@ -38,20 +39,6 @@ func (rt *impersonatingRoundTripper) RoundTrip(req *http.Request) (*http.Respons
38
39
return rt .delegate .RoundTrip (req )
39
40
}
40
41
41
- // cloneRequest returns a clone of the provided *http.Request.
42
- // The clone is a shallow copy of the struct and its Header map.
43
- func cloneRequest (r * http.Request ) * http.Request {
44
- // shallow copy of the struct
45
- r2 := new (http.Request )
46
- * r2 = * r
47
- // deep copy of the Header
48
- r2 .Header = make (http.Header )
49
- for k , s := range r .Header {
50
- r2 .Header [k ] = s
51
- }
52
- return r2
53
- }
54
-
55
42
// NewImpersonatingConfig wraps the config's transport to impersonate a user, including user, groups, and scopes
56
43
func NewImpersonatingConfig (user user.Info , config restclient.Config ) restclient.Config {
57
44
oldWrapTransport := config .WrapTransport
0 commit comments