From d0d4730c642d28a6bb7a702994f33e0e2a438cdc Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Wed, 23 Nov 2016 13:13:29 -0800 Subject: [PATCH] Add ttl option for records, defaults to 10 minutes --- main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 20e9f26..dfa9b96 100644 --- a/main.go +++ b/main.go @@ -40,7 +40,7 @@ func main() { app.Name = "update-dns" app.Usage = "update dns using dnsimple with public ip address" app.UsageText = "update-dns [options] host" - app.Version = "0.2.1" + app.Version = "0.3.0-dev" app.Action = action app.HideHelp = true @@ -58,6 +58,12 @@ func main() { Usage: "type of dns record to create", }, + cli.IntFlag{ + Name: "ttl", + Value: 600, + Usage: "time to live in seconds for dns record", + }, + cli.StringFlag{ Name: "content", Value: "", @@ -100,6 +106,7 @@ func action(context *cli.Context) error { host := context.Args().Get(0) kind := context.Generic("type").(*typeFlag).value + ttl := context.Int("ttl") wg.Add(1) ipClient := &ip.Client{ @@ -167,7 +174,8 @@ func action(context *cli.Context) error { 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") }