aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--acme.toml7
-rw-r--r--cmd/acme/config.go17
-rw-r--r--cmd/acme/config_test.go11
3 files changed, 22 insertions, 13 deletions
diff --git a/acme.toml b/acme.toml
index 05e52ce..eb801ce 100644
--- a/acme.toml
+++ b/acme.toml
@@ -1,17 +1,18 @@
+[[account]]
mail = "another@example.com"
key = "/etc/acme.key"
provider = "https://acme-staging.api.letsencrypt.org/directory"
-[[want]]
+[[account.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
-[[want]]
+[[account.want]]
domains = [ "www.example.net", "example.net" ]
cert = "/etc/certs/www_example_net.pem"
key = "/etc/private/www_example_net.key"
-[hook]
+[[account.hook]]
cmd = "sudo service nginx reload"
diff --git a/cmd/acme/config.go b/cmd/acme/config.go
index b880c11..c12732f 100644
--- a/cmd/acme/config.go
+++ b/cmd/acme/config.go
@@ -6,12 +6,16 @@ import (
"github.com/BurntSushi/toml"
)
+type Config struct {
+ Account []Account
+}
+
type Account struct {
Mail string
Key string
Provider string
Want []Want
- Hook Hook
+ Hook []Hook
}
type Want struct {
@@ -24,18 +28,11 @@ type Hook struct {
CMD string
}
-func ReadConfig(fname string) Account {
- var c Account
+func ReadConfig(fname string) Config {
+ var c Config
_, err := toml.DecodeFile(fname, &c)
if err != nil {
log.Fatal(err)
}
return c
}
-
-/*
-func main() {
- a := ReadConfig("acme.toml")
- log.Printf("%+v\n", a)
-}
-*/
diff --git a/cmd/acme/config_test.go b/cmd/acme/config_test.go
new file mode 100644
index 0000000..0aa473a
--- /dev/null
+++ b/cmd/acme/config_test.go
@@ -0,0 +1,11 @@
+package main
+
+import (
+ "fmt"
+ "testing"
+)
+
+func TestReadConfig(t *testing.T) {
+ a := ReadConfig("../../acme.toml")
+ t.Log(fmt.Sprintf("%+v\n", a))
+}