forked from grafana/grafana-plugin-sdk-go
/
options.go
131 lines (106 loc) · 3.7 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package httpclient
import (
"crypto/tls"
"net/http"
"time"
"github.com/kosimas/grafana-plugin-sdk-go/backend/proxy"
)
// ConfigureClientFunc function signature for configuring http.Client.
// Called after http.Client creation.
type ConfigureClientFunc func(opts Options, client *http.Client)
// ConfigureTransportFunc function signature for configuring http.Transport.
// Called after http.Transport creation.
type ConfigureTransportFunc func(opts Options, transport *http.Transport)
// ConfigureTLSConfigFunc function signature for configuring tls.Config.
// Called after tls.Config creation.
type ConfigureTLSConfigFunc func(opts Options, tlsConfig *tls.Config)
// Options defines options for creating HTTP clients.
type Options struct {
// Timeouts timeout/connection related options.
Timeouts *TimeoutOptions
// BasicAuth basic authentication related options.
BasicAuth *BasicAuthOptions
// TLS TLS related options.
TLS *TLSOptions
SigV4 *SigV4Config
// Proxy related options.
ProxyOptions *proxy.Options
// Headers custom headers.
Headers map[string]string
// CustomOptions allows custom options to be provided.
CustomOptions map[string]interface{}
// Labels could be used by certain middlewares.
Labels map[string]string
// Middlewares optionally provide additional middlewares.
Middlewares []Middleware
// ConfigureMiddleware optionally provide a ConfigureMiddlewareFunc
// to modify the middlewares chain.
ConfigureMiddleware ConfigureMiddlewareFunc
// ConfigureClient optionally provide a ConfigureClientFunc
// to modify the created http.Client.
ConfigureClient ConfigureClientFunc
// ConfigureTransport optionally provide a ConfigureTransportFunc
// to modify the created http.Client.
ConfigureTransport ConfigureTransportFunc
// ConfigureTLSConfig optionally provide a ConfigureTLSConfigFunc
// to modify the created http.Client.
ConfigureTLSConfig ConfigureTLSConfigFunc
// ForwardHTTPHeaders enable forwarding of all HTTP headers
// included in backend.QueryDataRequest, backend.CallResourceRequest,
// backend.CheckHealthRequest, e.g. based on if Allowed cookies or
// Forward OAuth Identity is configured for the datasource or any
// other forwarded HTTP header from Grafana.
ForwardHTTPHeaders bool
}
// BasicAuthOptions basic authentication options.
type BasicAuthOptions struct {
User string
Password string
}
// TimeoutOptions timeout/connection options.
type TimeoutOptions struct {
Timeout time.Duration
DialTimeout time.Duration
KeepAlive time.Duration
TLSHandshakeTimeout time.Duration
ExpectContinueTimeout time.Duration
MaxConnsPerHost int
MaxIdleConns int
MaxIdleConnsPerHost int
IdleConnTimeout time.Duration
}
// DefaultTimeoutOptions default timeout/connection options.
var DefaultTimeoutOptions = TimeoutOptions{
Timeout: 30 * time.Second,
DialTimeout: 10 * time.Second,
KeepAlive: 30 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
MaxConnsPerHost: 0,
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
IdleConnTimeout: 90 * time.Second,
}
// TLSOptions TLS options.
type TLSOptions struct {
CACertificate string
ClientCertificate string
ClientKey string
InsecureSkipVerify bool
ServerName string
// MinVersion configures the tls.Config.MinVersion.
MinVersion uint16
// MaxVersion configures the tls.Config.MaxVersion.
MaxVersion uint16
}
// SigV4Config AWS SigV4 options.
type SigV4Config struct {
AuthType string
Profile string
Service string
AccessKey string
SecretKey string
AssumeRoleARN string
ExternalID string
Region string
}