/
types.go
52 lines (44 loc) · 2.08 KB
/
types.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
package grafana
import (
"io"
"gopkg.in/yaml.v2"
)
type DataSource struct {
Id int64 `json:"id" yaml:"-"`
OrgId int64 `json:"orgId" yaml:"orgId,omitempty"`
Version int `json:"version" yaml:"version,omitempty"`
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Access string `json:"access" yaml:"access"`
Url string `json:"url" yaml:"url,omitempty"`
Password string `json:"password" yaml:"password,omitempty"`
User string `json:"user" yaml:"user,omitempty"`
Database string `json:"database" yaml:"database,omitempty"`
BasicAuth bool `json:"basicAuth" yaml:"basicAuth,omitempty"`
BasicAuthUser string `json:"basicAuthUser" yaml:"basicAuthUser,omitempty"`
BasicAuthPassword string `json:"basicAuthPassword" yaml:"basicAuthPassword,omitempty"`
WithCredentials bool `json:"withCredentials" yaml:"withCredentials,omitempty"`
IsDefault bool `json:"isDefault" yaml:"isDefault,omitempty"`
JsonData map[string]interface{} `json:"jsonData" yaml:"jsonData,omitempty"`
SecureJsonFields map[string]bool `json:"secureJsonFields" yaml:"-"`
SecureJsonData map[string]string `json:"secureJsonData" yaml:"secureJsonData,omitempty"`
Editable bool `json:"editable" yaml:"editable,omitempty"`
ReadOnly bool `json:"readOnly" yaml:"-"`
}
type DataSourceProvisioning struct {
ApiVersion int64 `yaml:"apiVersion"`
Datasources []*DataSource `yaml:"datasources"`
}
func (dsp *DataSourceProvisioning) WriteTo(out io.Writer) error {
var (
yamlBytes []byte
err error
)
if yamlBytes, err = yaml.Marshal(dsp); err != nil {
return err
}
if _, err = out.Write(yamlBytes); err != nil {
return err
}
return nil
}