From 91cc9d2f53932f42afe89245f346a97b45edda9f Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 17 Dec 2015 01:11:23 +0100 Subject: Add duration type --- cmd/acmed/config.go | 11 ++++++++++- cmd/acmed/main.go | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/acmed/config.go b/cmd/acmed/config.go index cc95557..284ae61 100644 --- a/cmd/acmed/config.go +++ b/cmd/acmed/config.go @@ -5,6 +5,7 @@ import ( "errors" "path" "strings" + "time" "github.com/BurntSushi/toml" ) @@ -18,7 +19,7 @@ type Config struct { } type defaults struct { - Gracetime string + Gracetime duration Listen string Provider string Account string @@ -139,3 +140,11 @@ func (d desire) Path() string { return d.Key } func (d desire) Size() int { return d.KeySize } func (a account) Path() string { return a.Key } func (a account) Size() int { return a.KeySize } + +type duration struct{ time.Duration } + +func (d *duration) UnmarshalText(s []byte) error { + var err error + d.Duration, err = time.ParseDuration(string(s)) + return err +} diff --git a/cmd/acmed/main.go b/cmd/acmed/main.go index abf560f..6963238 100644 --- a/cmd/acmed/main.go +++ b/cmd/acmed/main.go @@ -76,6 +76,9 @@ func main() { conf.Desire[k] = des } + log.Println(conf) + return + for k, des := range conf.Desire { a, _ := acme.NewAccount(des.account.Mail, des.account.Phone, des.account.key) log.Println(k, a) -- cgit v1.2.3