forked from lucasgolino/cloudflare-zone-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
52 lines (41 loc) · 941 Bytes
/
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
package czm
import (
cfgo "github.com/cloudflare/cloudflare-go"
SLog "github.com/quan-to/slog"
"gopkg.in/yaml.v2"
"io/ioutil"
)
type DNSMetadata struct {
Key string `yaml:"key"`
Data string `yaml:"data"`
}
type Dns struct {
ID string
Name string `yaml:"name"`
Dtype string `yaml:"dtype"`
Content string `yaml:"content"`
Proxied bool `yaml:"proxied"`
Rules Rules `yaml:"rules"`
TTL int `yaml:"ttl"`
Module Module `yaml:"module"`
}
type Zone struct {
Id string `yaml:"id"`
Hostname string `yaml:"hostname"`
Dns []Dns `yaml:"dns"`
DNSRecords []cfgo.DNSRecord
}
type ConfigMap struct {
Cloudflare Cloudflare `yaml:"cloudflare"`
Zones []Zone `yaml:"zones"`
}
func (cMap *ConfigMap) ReadConfigMap() {
yamlFile, err := ioutil.ReadFile(CONFIG_MAP_PATH)
if err != nil {
SLog.Scope("ReadZones").Error(err)
}
err = yaml.Unmarshal(yamlFile, &cMap)
if err != nil {
SLog.Scope("ReadZones").Error(err)
}
}