@@ -17,25 +17,29 @@ import (
17
17
)
18
18
19
19
type Tdengine struct {
20
- DatasourceName string `json:"tdengine.datasource_name" mapstructure:"tdengine.datasource_name"`
21
- Addr string `json:"tdengine.addr" mapstructure:"tdengine.addr"`
22
- BasicAuthUser string `json:"tdengine.basic_auth_user" mapstructure:"tdengine.basic_auth_user"`
23
- BasicAuthPass string `json:"tdengine.basic_auth_pass" mapstructure:"tdengine.basic_auth_pass"`
24
- Token string `json:"tdengine.token" mapstructure:"tdengine.token"`
25
-
26
- Timeout int64 `json:"tdengine.timeout" mapstructure:"tdengine.timeout"`
27
- DialTimeout int64 `json:"tdengine.dial_timeout" mapstructure:"tdengine.dial_timeout"`
28
-
29
- MaxIdleConnsPerHost int `json:"tdengine.max_idle_conns_per_host" mapstructure:"tdengine.max_idle_conns_per_host"`
30
-
31
- Headers map [string ]string `json:"tdengine.headers" mapstructure:"tdengine.headers"`
20
+ DatasourceName string `json:"tdengine.datasource_name" mapstructure:"tdengine.datasource_name"`
21
+ Addr string `json:"tdengine.addr" mapstructure:"tdengine.addr"`
22
+ Basic * TDengineBasicAuth `json:"tdengine.basic"`
23
+ Token string `json:"tdengine.token" mapstructure:"tdengine.token"`
24
+ Timeout int64 `json:"tdengine.timeout" mapstructure:"tdengine.timeout"`
25
+ DialTimeout int64 `json:"tdengine.dial_timeout" mapstructure:"tdengine.dial_timeout"`
26
+ MaxIdleConnsPerHost int `json:"tdengine.max_idle_conns_per_host" mapstructure:"tdengine.max_idle_conns_per_host"`
27
+ Headers map [string ]string `json:"tdengine.headers" mapstructure:"tdengine.headers"`
28
+ SkipTlsVerify bool `json:"tdengine.skip_tls_verify"`
29
+ ClusterName string `json:"tdengine.cluster_name"`
32
30
33
31
tlsx.ClientConfig
34
32
35
33
header map [string ][]string `json:"-"`
36
34
client * http.Client `json:"-"`
37
35
}
38
36
37
+ type TDengineBasicAuth struct {
38
+ User string `json:"tdengine.user"`
39
+ Password string `json:"tdengine.password"`
40
+ IsEncrypt bool `json:"tdengine.is_encrypt"`
41
+ }
42
+
39
43
type APIResponse struct {
40
44
Code int `json:"code"`
41
45
ColumnMeta [][]interface {} `json:"column_meta"`
@@ -76,8 +80,8 @@ func (tc *Tdengine) InitCli() {
76
80
tc .header [k ] = []string {v }
77
81
}
78
82
79
- if tc .BasicAuthUser != "" {
80
- basic := base64 .StdEncoding .EncodeToString ([]byte (tc .BasicAuthUser + ":" + tc .BasicAuthPass ))
83
+ if tc .Basic != nil {
84
+ basic := base64 .StdEncoding .EncodeToString ([]byte (tc .Basic . User + ":" + tc .Basic . Password ))
81
85
tc .header ["Authorization" ] = []string {fmt .Sprintf ("Basic %s" , basic )}
82
86
}
83
87
}
0 commit comments