Always send basic auth in jenkins input (#5329)

This commit is contained in:
Daniel Nelson 2019-01-23 14:17:57 -08:00 committed by GitHub
parent aabb60dfec
commit d1610d50e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 31 deletions

View File

@ -15,10 +15,10 @@ This plugin does not require a plugin on jenkins and it makes use of Jenkins API
## Set response_timeout
response_timeout = "5s"
## Optional SSL Config
# ssl_ca = /path/to/cafile
# ssl_cert = /path/to/certfile
# ssl_key = /path/to/keyfile
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use SSL but skip chain & host verification
# insecure_skip_verify = false

View File

@ -33,8 +33,7 @@ func (c *client) init() error {
if err != nil {
return err
}
if c.username != "" && c.password != "" {
// set auth
if c.username != "" || c.password != "" {
req.SetBasicAuth(c.username, c.password)
}
resp, err := c.httpClient.Do(req)
@ -123,10 +122,11 @@ func createGetRequest(url string, username, password string, sessionCookie *http
if err != nil {
return nil, err
}
if username != "" || password != "" {
req.SetBasicAuth(username, password)
}
if sessionCookie != nil {
req.AddCookie(sessionCookie)
} else if username != "" && password != "" {
req.SetBasicAuth(username, password)
}
req.Header.Add("Accept", "application/json")
return req, nil

View File

@ -51,10 +51,10 @@ const sampleConfig = `
## Set response_timeout
response_timeout = "5s"
## Optional SSL Config
# ssl_ca = /path/to/cafile
# ssl_cert = /path/to/certfile
# ssl_key = /path/to/keyfile
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use SSL but skip chain & host verification
# insecure_skip_verify = false