File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,7 +96,9 @@ type ClientOpts struct {
9696var ErrCIAccessTokenRequired = errors .New ("SRC_ACCESS_TOKEN must be set when CI=true" )
9797
9898func buildTransport (opts ClientOpts , flags * Flags ) http.RoundTripper {
99- transport := http .DefaultTransport .(* http.Transport ).Clone ()
99+ var transport http.RoundTripper
100+ {
101+ tp := http .DefaultTransport .(* http.Transport ).Clone ()
100102
101103 if flags .insecureSkipVerify != nil && * flags .insecureSkipVerify {
102104 transport .TLSClientConfig = & tls.Config {InsecureSkipVerify : true }
@@ -108,7 +110,15 @@ func buildTransport(opts ClientOpts, flags *Flags) http.RoundTripper {
108110 if opts .AccessToken == "" && opts .OAuthToken != nil {
109111 transport = oauth .NewTransport (transport , opts .OAuthToken )
110112 }
111- return rt
113+
114+ // not we do not fail here if requireAccessToken is true, because that would
115+ // mean returning an error on construction which we want to avoid for now
116+ // TODO(burmudar): allow returning of an error upon client construction
117+ if opts .AccessToken == "" && opts .OAuthToken != nil {
118+ transport = oauth .NewTransport (transport , opts .OAuthToken )
119+ }
120+
121+ return transport
112122}
113123
114124// NewClient creates a new API client.
You can’t perform that action at this time.
0 commit comments