mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-26 19:49:33 +00:00
Propagate errors from NewClientTokenTLS back to caller.
This commit is contained in:
@@ -73,7 +73,7 @@ func NewClientToken(uri, token string) Client {
|
|||||||
|
|
||||||
// NewClientTokenTLS returns a client at the specified url that authenticates
|
// NewClientTokenTLS returns a client at the specified url that authenticates
|
||||||
// all outbound requests with the given token and tls.Config if provided.
|
// 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)
|
config := new(oauth2.Config)
|
||||||
auther := config.Client(oauth2.NoContext, &oauth2.Token{AccessToken: token})
|
auther := config.Client(oauth2.NoContext, &oauth2.Token{AccessToken: token})
|
||||||
if c != nil {
|
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)
|
dialer, err := proxy.SOCKS5("tcp", os.Getenv("SOCKS_PROXY"), nil, proxy.Direct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "can't connect to the proxy:", err)
|
fmt.Fprintln(os.Stderr, "can't connect to the proxy:", err)
|
||||||
os.Exit(1)
|
return nil, err
|
||||||
}
|
}
|
||||||
trans.Base = &http.Transport{
|
trans.Base = &http.Transport{
|
||||||
TLSClientConfig: c,
|
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.
|
// Self returns the currently authenticated user.
|
||||||
|
@@ -31,7 +31,7 @@ func newClient(c *cli.Context) (client.Client, error) {
|
|||||||
tlsConfig := &tls.Config{RootCAs: certs}
|
tlsConfig := &tls.Config{RootCAs: certs}
|
||||||
|
|
||||||
// create the drone client with TLS options
|
// 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) {
|
func parseRepo(str string) (user, repo string, err error) {
|
||||||
|
Reference in New Issue
Block a user