mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Added attribute proxy for mc admin config set ALIAS logger_webhook
(#16657)
Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
parent
9202c6e26a
commit
6b65ba1551
@ -43,6 +43,7 @@ const (
|
|||||||
ClientCert = "client_cert"
|
ClientCert = "client_cert"
|
||||||
ClientKey = "client_key"
|
ClientKey = "client_key"
|
||||||
QueueSize = "queue_size"
|
QueueSize = "queue_size"
|
||||||
|
Proxy = "proxy"
|
||||||
|
|
||||||
KafkaBrokers = "brokers"
|
KafkaBrokers = "brokers"
|
||||||
KafkaTopic = "topic"
|
KafkaTopic = "topic"
|
||||||
@ -62,6 +63,7 @@ const (
|
|||||||
EnvLoggerWebhookAuthToken = "MINIO_LOGGER_WEBHOOK_AUTH_TOKEN"
|
EnvLoggerWebhookAuthToken = "MINIO_LOGGER_WEBHOOK_AUTH_TOKEN"
|
||||||
EnvLoggerWebhookClientCert = "MINIO_LOGGER_WEBHOOK_CLIENT_CERT"
|
EnvLoggerWebhookClientCert = "MINIO_LOGGER_WEBHOOK_CLIENT_CERT"
|
||||||
EnvLoggerWebhookClientKey = "MINIO_LOGGER_WEBHOOK_CLIENT_KEY"
|
EnvLoggerWebhookClientKey = "MINIO_LOGGER_WEBHOOK_CLIENT_KEY"
|
||||||
|
EnvLoggerWebhookProxy = "MINIO_LOGGER_WEBHOOK_PROXY"
|
||||||
EnvLoggerWebhookQueueSize = "MINIO_LOGGER_WEBHOOK_QUEUE_SIZE"
|
EnvLoggerWebhookQueueSize = "MINIO_LOGGER_WEBHOOK_QUEUE_SIZE"
|
||||||
|
|
||||||
EnvAuditWebhookEnable = "MINIO_AUDIT_WEBHOOK_ENABLE"
|
EnvAuditWebhookEnable = "MINIO_AUDIT_WEBHOOK_ENABLE"
|
||||||
@ -109,6 +111,10 @@ var (
|
|||||||
Key: ClientKey,
|
Key: ClientKey,
|
||||||
Value: "",
|
Value: "",
|
||||||
},
|
},
|
||||||
|
config.KV{
|
||||||
|
Key: Proxy,
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
config.KV{
|
config.KV{
|
||||||
Key: QueueSize,
|
Key: QueueSize,
|
||||||
Value: "100000",
|
Value: "100000",
|
||||||
@ -441,6 +447,7 @@ func lookupLoggerWebhookConfig(scfg config.Config, cfg Config) (Config, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, err
|
return cfg, err
|
||||||
}
|
}
|
||||||
|
proxyEnv := EnvLoggerWebhookProxy
|
||||||
queueSizeEnv := EnvAuditWebhookQueueSize
|
queueSizeEnv := EnvAuditWebhookQueueSize
|
||||||
if target != config.Default {
|
if target != config.Default {
|
||||||
queueSizeEnv = EnvAuditWebhookQueueSize + config.Default + target
|
queueSizeEnv = EnvAuditWebhookQueueSize + config.Default + target
|
||||||
@ -458,6 +465,7 @@ func lookupLoggerWebhookConfig(scfg config.Config, cfg Config) (Config, error) {
|
|||||||
AuthToken: env.Get(authTokenEnv, ""),
|
AuthToken: env.Get(authTokenEnv, ""),
|
||||||
ClientCert: env.Get(clientCertEnv, ""),
|
ClientCert: env.Get(clientCertEnv, ""),
|
||||||
ClientKey: env.Get(clientKeyEnv, ""),
|
ClientKey: env.Get(clientKeyEnv, ""),
|
||||||
|
Proxy: env.Get(proxyEnv, ""),
|
||||||
QueueSize: queueSize,
|
QueueSize: queueSize,
|
||||||
Name: target,
|
Name: target,
|
||||||
}
|
}
|
||||||
@ -501,6 +509,7 @@ func lookupLoggerWebhookConfig(scfg config.Config, cfg Config) (Config, error) {
|
|||||||
AuthToken: kv.Get(AuthToken),
|
AuthToken: kv.Get(AuthToken),
|
||||||
ClientCert: kv.Get(ClientCert),
|
ClientCert: kv.Get(ClientCert),
|
||||||
ClientKey: kv.Get(ClientKey),
|
ClientKey: kv.Get(ClientKey),
|
||||||
|
Proxy: kv.Get(Proxy),
|
||||||
QueueSize: queueSize,
|
QueueSize: queueSize,
|
||||||
Name: starget,
|
Name: starget,
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,12 @@ var (
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Type: "number",
|
Type: "number",
|
||||||
},
|
},
|
||||||
|
config.HelpKV{
|
||||||
|
Key: Proxy,
|
||||||
|
Description: "proxy url endpoint e.g. http(s)://proxy",
|
||||||
|
Optional: true,
|
||||||
|
Type: "string",
|
||||||
|
},
|
||||||
config.HelpKV{
|
config.HelpKV{
|
||||||
Key: config.Comment,
|
Key: config.Comment,
|
||||||
Description: config.DefaultComment,
|
Description: config.DefaultComment,
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -51,6 +52,7 @@ type Config struct {
|
|||||||
ClientCert string `json:"clientCert"`
|
ClientCert string `json:"clientCert"`
|
||||||
ClientKey string `json:"clientKey"`
|
ClientKey string `json:"clientKey"`
|
||||||
QueueSize int `json:"queueSize"`
|
QueueSize int `json:"queueSize"`
|
||||||
|
Proxy string `json:"string"`
|
||||||
Transport http.RoundTripper `json:"-"`
|
Transport http.RoundTripper `json:"-"`
|
||||||
|
|
||||||
// Custom logger
|
// Custom logger
|
||||||
@ -127,6 +129,15 @@ func (h *Target) Init() error {
|
|||||||
req.Header.Set("Authorization", h.config.AuthToken)
|
req.Header.Set("Authorization", h.config.AuthToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If proxy available, set the same
|
||||||
|
if h.config.Proxy != "" {
|
||||||
|
proxyURL, _ := url.Parse(h.config.Proxy)
|
||||||
|
transport := h.config.Transport
|
||||||
|
ctransport := transport.(*http.Transport).Clone()
|
||||||
|
ctransport.Proxy = http.ProxyURL(proxyURL)
|
||||||
|
h.config.Transport = ctransport
|
||||||
|
}
|
||||||
|
|
||||||
client := http.Client{Transport: h.config.Transport}
|
client := http.Client{Transport: h.config.Transport}
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user