-
Notifications
You must be signed in to change notification settings - Fork 376
/
config.go
73 lines (60 loc) · 1.9 KB
/
config.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
package providers
import (
"net/http"
"time"
)
// PromConfig represents the config of prometheus
type PromConfig struct {
Address string
AdapterConfigMapNS string
AdapterConfigMapName string
AdapterConfigMapKey string
AdapterConfig string
AdapterExtensionLabels string
Timeout time.Duration
KeepAlive time.Duration
InsecureSkipVerify bool
Auth ClientAuth
QueryConcurrency int
BRateLimit bool
MaxPointsLimitPerTimeSeries int
}
// ClientAuth holds the HTTP client identity info.
type ClientAuth struct {
Username string
BearerToken string
Password string
}
// Apply applies the authentication identity info to the HTTP request headers
func (auth *ClientAuth) Apply(req *http.Request) {
if auth == nil {
return
}
if auth.BearerToken != "" {
token := "Bearer " + auth.BearerToken
req.Header.Add("Authorization", token)
}
if auth.Username != "" {
req.SetBasicAuth(auth.Username, auth.Password)
}
}
// MockConfig represents the config of an in-memory provider, which is for demonstration or testing purpose.
type MockConfig struct {
SeedFile string
}
type GrpcConfig struct {
Address string
Timeout time.Duration
}
type DataSourceType string
const (
MockDataSource DataSourceType = "mock"
PrometheusDataSource DataSourceType = "prom"
MetricServerDataSource DataSourceType = "metricserver"
GrpcDataSource DataSourceType = "grpc"
DataSourceTypeKey string = "data-source-type"
)
var PrometheusConfigKeys = []string{"prometheus-address", "prometheus-auth-username", "prometheus-auth-password",
"prometheus-auth-bearertoken", "prometheus-query-concurrency", "prometheus-insecure-skip-verify",
"prometheus-keepalive", "prometheus-timeout", "prometheus-bratelimit", "prometheus-maxpoints"}
var GrpcConfigKeys = []string{"grpc-ds-address", "grpc-ds-timeout"}