mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Support passing the JSON as a parameter (#147)
* Support passing the JSON as a parameter This allows dnscontrol to be able to be used with other tools that support outputting to it's intermediate JSON format. Closes #73 * Pass dnsConfig pointer to Unmarshal
This commit is contained in:
12
main.go
12
main.go
@ -25,6 +25,7 @@ import (
|
||||
|
||||
var jsFile = flag.String("js", "dnsconfig.js", "Javascript file containing dns config")
|
||||
var credsFile = flag.String("creds", "creds.json", "Provider credentials JSON file")
|
||||
var jsonFile = flag.String("json", "", "File containing intermediate JSON")
|
||||
|
||||
var jsonOutputPre = flag.String("debugrawjson", "", "Write JSON intermediate to this file pre-normalization.")
|
||||
var jsonOutputPost = flag.String("debugjson", "", "During preview, write JSON intermediate to this file instead of stdout.")
|
||||
@ -46,7 +47,16 @@ func main() {
|
||||
}
|
||||
|
||||
var dnsConfig *models.DNSConfig
|
||||
if *jsFile != "" {
|
||||
if *jsonFile != "" {
|
||||
text, err := ioutil.ReadFile(*jsonFile)
|
||||
if err != nil {
|
||||
log.Fatalf("Error reading %v: %v\n", *jsonFile, err)
|
||||
}
|
||||
err = json.Unmarshal(text, &dnsConfig)
|
||||
if err != nil {
|
||||
log.Fatalf("Error parsing JSON in (%v): %v", *jsonFile, err)
|
||||
}
|
||||
} else if *jsFile != "" {
|
||||
text, err := ioutil.ReadFile(*jsFile)
|
||||
if err != nil {
|
||||
log.Fatalf("Error reading %v: %v\n", *jsFile, err)
|
||||
|
Reference in New Issue
Block a user