mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
Propagate errors from NewClientTokenTLS back to caller.
This commit is contained in:
parent
a64696df68
commit
eb7e79e887
2 changed files with 4 additions and 4 deletions
|
@ -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.
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue