From eb7e79e887f2d0377f1ea29cc5be5c60552fae75 Mon Sep 17 00:00:00 2001 From: "Veg (Martin Wellard)" Date: Wed, 18 Jan 2017 10:26:46 -0500 Subject: [PATCH] Propagate errors from NewClientTokenTLS back to caller. --- client/client_impl.go | 6 +++--- drone/util.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/client_impl.go b/client/client_impl.go index 96a16a50..1aea4a3d 100644 --- a/client/client_impl.go +++ b/client/client_impl.go @@ -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. diff --git a/drone/util.go b/drone/util.go index e90d39b5..da3be255 100644 --- a/drone/util.go +++ b/drone/util.go @@ -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) {