Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export transport constructors #19887

Merged
merged 1 commit into from
Jan 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/client/transport/round_trippers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ func HTTPWrappersForConfig(config *Config, rt http.RoundTripper) (http.RoundTrip
case config.HasBasicAuth() && config.HasTokenAuth():
return nil, fmt.Errorf("username/password or bearer token may be set, but not both")
case config.HasTokenAuth():
rt = newBearerAuthRoundTripper(config.BearerToken, rt)
rt = NewBearerAuthRoundTripper(config.BearerToken, rt)
case config.HasBasicAuth():
rt = newBasicAuthRoundTripper(config.Username, config.Password, rt)
rt = NewBasicAuthRoundTripper(config.Username, config.Password, rt)
}
if len(config.UserAgent) > 0 {
rt = newUserAgentRoundTripper(config.UserAgent, rt)
rt = NewUserAgentRoundTripper(config.UserAgent, rt)
}
return rt, nil
}
Expand Down Expand Up @@ -76,7 +76,7 @@ type userAgentRoundTripper struct {
rt http.RoundTripper
}

func newUserAgentRoundTripper(agent string, rt http.RoundTripper) http.RoundTripper {
func NewUserAgentRoundTripper(agent string, rt http.RoundTripper) http.RoundTripper {
return &userAgentRoundTripper{agent, rt}
}

Expand Down Expand Up @@ -105,7 +105,7 @@ type basicAuthRoundTripper struct {

// NewBasicAuthRoundTripper will apply a BASIC auth authorization header to a
// request unless it has already been set.
func newBasicAuthRoundTripper(username, password string, rt http.RoundTripper) http.RoundTripper {
func NewBasicAuthRoundTripper(username, password string, rt http.RoundTripper) http.RoundTripper {
return &basicAuthRoundTripper{username, password, rt}
}

Expand Down Expand Up @@ -133,7 +133,7 @@ type bearerAuthRoundTripper struct {

// NewBearerAuthRoundTripper adds the provided bearer token to a request
// unless the authorization header has already been set.
func newBearerAuthRoundTripper(bearer string, rt http.RoundTripper) http.RoundTripper {
func NewBearerAuthRoundTripper(bearer string, rt http.RoundTripper) http.RoundTripper {
return &bearerAuthRoundTripper{bearer, rt}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/client/transport/round_trippers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (rt *testRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
func TestBearerAuthRoundTripper(t *testing.T) {
rt := &testRoundTripper{}
req := &http.Request{}
newBearerAuthRoundTripper("test", rt).RoundTrip(req)
NewBearerAuthRoundTripper("test", rt).RoundTrip(req)
if rt.Request == nil {
t.Fatalf("unexpected nil request: %v", rt)
}
Expand All @@ -57,7 +57,7 @@ func TestBasicAuthRoundTripper(t *testing.T) {
} {
rt := &testRoundTripper{}
req := &http.Request{}
newBasicAuthRoundTripper(tc.user, tc.pass, rt).RoundTrip(req)
NewBasicAuthRoundTripper(tc.user, tc.pass, rt).RoundTrip(req)
if rt.Request == nil {
t.Fatalf("%s: unexpected nil request: %v", n, rt)
}
Expand All @@ -76,7 +76,7 @@ func TestUserAgentRoundTripper(t *testing.T) {
Header: make(http.Header),
}
req.Header.Set("User-Agent", "other")
newUserAgentRoundTripper("test", rt).RoundTrip(req)
NewUserAgentRoundTripper("test", rt).RoundTrip(req)
if rt.Request == nil {
t.Fatalf("unexpected nil request: %v", rt)
}
Expand All @@ -88,7 +88,7 @@ func TestUserAgentRoundTripper(t *testing.T) {
}

req = &http.Request{}
newUserAgentRoundTripper("test", rt).RoundTrip(req)
NewUserAgentRoundTripper("test", rt).RoundTrip(req)
if rt.Request == nil {
t.Fatalf("unexpected nil request: %v", rt)
}
Expand Down