From e4c8ad0132c4ba03bd651beeaaa7cbb6e3b86eb4 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 6 Dec 2015 17:44:47 +0100 Subject: Adjust parser --- acme.toml | 7 +++---- cmd/acme/config.go | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/acme.toml b/acme.toml index eb801ce..05e52ce 100644 --- a/acme.toml +++ b/acme.toml @@ -1,18 +1,17 @@ -[[account]] mail = "another@example.com" key = "/etc/acme.key" provider = "https://acme-staging.api.letsencrypt.org/directory" -[[account.want]] +[[want]] domains = [ "www.example.com", "example.com" ] cert = "/etc/certs/www_example_com.pem" key = "/etc/private/www_example_com.key" # webroot = /var/www/htdocs -[[account.want]] +[[want]] domains = [ "www.example.net", "example.net" ] cert = "/etc/certs/www_example_net.pem" key = "/etc/private/www_example_net.key" -[[account.hook]] +[hook] cmd = "sudo service nginx reload" diff --git a/cmd/acme/config.go b/cmd/acme/config.go index 24d7820..b880c11 100644 --- a/cmd/acme/config.go +++ b/cmd/acme/config.go @@ -6,16 +6,12 @@ import ( "github.com/BurntSushi/toml" ) -type Config struct { - Account Account - Want []Want - Hook []Hook -} - type Account struct { Mail string Key string Provider string + Want []Want + Hook Hook } type Want struct { @@ -28,11 +24,18 @@ type Hook struct { CMD string } -func ReadConfig(fname string) Config { - var c Config +func ReadConfig(fname string) Account { + var c Account _, err := toml.DecodeFile(fname, &c) if err != nil { log.Fatal(err) } return c } + +/* +func main() { + a := ReadConfig("acme.toml") + log.Printf("%+v\n", a) +} +*/ -- cgit v1.2.3