-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.go
38 lines (35 loc) · 1.12 KB
/
output.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
package entity
import (
"github.com/mitchellh/mapstructure"
"os"
)
type Output struct {
Type string
HttpURL string `mapstructure:"http_url"`
HttpHeaders map[string]string `mapstructure:"http_headers"`
RedisAddr string `mapstructure:"redis_addr"`
RedisDB int `mapstructure:"redis_db"`
RedisKey string `mapstructure:"redis_key"`
MySQLHost string `mapstructure:"mysql_host"`
MySQLPort int `mapstructure:"mysql_port"`
MySQLDb string `mapstructure:"mysql_db"`
MySQLUser string `mapstructure:"mysql_user"`
MySQLPassword string `mapstructure:"mysql_password"`
HostName string
}
func NewOutputs(outputData map[string]interface{}) (map[string]Output, error) {
outputs := make(map[string]Output)
for label, outputObj := range outputData {
output := Output{}
err := mapstructure.Decode(outputObj, &output)
if err != nil {
return nil, err
}
output.HostName, err = os.Hostname()
if err != nil {
return nil, err
}
outputs[label] = output
}
return outputs, nil
}