diff --git a/client/client_impl.go b/client/client_impl.go index 96a16a503..1aea4a3d8 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 e90d39b53..da3be2550 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) {