Propagate errors from NewClientTokenTLS back to caller.

This commit is contained in:
Veg (Martin Wellard) 2017-01-18 10:26:46 -05:00
parent a64696df68
commit eb7e79e887
2 changed files with 4 additions and 4 deletions

View file

@ -73,7 +73,7 @@ func NewClientToken(uri, token string) Client {
// NewClientTokenTLS returns a client at the specified url that authenticates
// all outbound requests with the given token and tls.Config if provided.
func NewClientTokenTLS(uri, token string, c *tls.Config) Client {
func NewClientTokenTLS(uri, token string, c *tls.Config) (Client, error) {
config := new(oauth2.Config)
auther := config.Client(oauth2.NoContext, &oauth2.Token{AccessToken: token})
if c != nil {
@ -82,7 +82,7 @@ func NewClientTokenTLS(uri, token string, c *tls.Config) Client {
dialer, err := proxy.SOCKS5("tcp", os.Getenv("SOCKS_PROXY"), nil, proxy.Direct)
if err != nil {
fmt.Fprintln(os.Stderr, "can't connect to the proxy:", err)
os.Exit(1)
return nil, err
}
trans.Base = &http.Transport{
TLSClientConfig: c,
@ -97,7 +97,7 @@ func NewClientTokenTLS(uri, token string, c *tls.Config) Client {
}
}
}
return &client{client: auther, base: uri, token: token}
return &client{client: auther, base: uri, token: token}, nil
}
// Self returns the currently authenticated user.

View file

@ -31,7 +31,7 @@ func newClient(c *cli.Context) (client.Client, error) {
tlsConfig := &tls.Config{RootCAs: certs}
// create the drone client with TLS options
return client.NewClientTokenTLS(server, token, tlsConfig), nil
return client.NewClientTokenTLS(server, token, tlsConfig)
}
func parseRepo(str string) (user, repo string, err error) {