Add ttl option for records, defaults to 10 minutes

master
Buddy Sandidge 8 years ago
parent 0ff252d918
commit d0d4730c64

@ -40,7 +40,7 @@ func main() {
app.Name = "update-dns" app.Name = "update-dns"
app.Usage = "update dns using dnsimple with public ip address" app.Usage = "update dns using dnsimple with public ip address"
app.UsageText = "update-dns [options] host" app.UsageText = "update-dns [options] host"
app.Version = "0.2.1" app.Version = "0.3.0-dev"
app.Action = action app.Action = action
app.HideHelp = true app.HideHelp = true
@ -58,6 +58,12 @@ func main() {
Usage: "type of dns record to create", Usage: "type of dns record to create",
}, },
cli.IntFlag{
Name: "ttl",
Value: 600,
Usage: "time to live in seconds for dns record",
},
cli.StringFlag{ cli.StringFlag{
Name: "content", Name: "content",
Value: "", Value: "",
@ -100,6 +106,7 @@ func action(context *cli.Context) error {
host := context.Args().Get(0) host := context.Args().Get(0)
kind := context.Generic("type").(*typeFlag).value kind := context.Generic("type").(*typeFlag).value
ttl := context.Int("ttl")
wg.Add(1) wg.Add(1)
ipClient := &ip.Client{ ipClient := &ip.Client{
@ -167,7 +174,8 @@ func action(context *cli.Context) error {
return nil return nil
} }
if err := client.CreateRecord(host, dns.Record{Type: kind, Content: content}); err != nil { newRecord := dns.Record{Type: kind, Content: content, TTL: ttl}
if err := client.CreateRecord(host, newRecord); err != nil {
return errors.Wrap(err, "could not create record") return errors.Wrap(err, "could not create record")
} }

Loading…
Cancel
Save