mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-12-25 17:21:47 +08: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:
parent
06461d3bca
commit
bce99a1c25
1 changed files with 11 additions and 1 deletions
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)
|
||||
|
|
Loading…
Reference in a new issue