aboutsummaryrefslogtreecommitdiff
path: root/cmd/acme/config.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-15 09:09:40 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-03-15 09:09:40 +0100
commit1d338e266441d64963d9ff93d343074f4d87bb15 (patch)
tree24091a855f3fc565c2a3bec6500600fb65c10619 /cmd/acme/config.go
parentb55ed6360737c4dc34eb76a21209e7f879ed6ddd (diff)
Flatten config tree
Diffstat (limited to 'cmd/acme/config.go')
-rw-r--r--cmd/acme/config.go79
1 files changed, 35 insertions, 44 deletions
diff --git a/cmd/acme/config.go b/cmd/acme/config.go
index bec6a19..693f827 100644
--- a/cmd/acme/config.go
+++ b/cmd/acme/config.go
@@ -27,13 +27,9 @@ type Config struct {
ListenTLS string
BaseDir string
KeySize int
- Provider []provider
- Hook map[string]string
-}
-
-type provider struct {
Directory string
Account []account
+ Hook map[string]string
}
type account struct {
@@ -92,52 +88,47 @@ func LoadConfig(fname string) (*Config, error) {
if c.KeySize == 0 {
c.KeySize = defKeySize
}
+ if c.Directory == "" {
+ c.Directory = acme.LE1
+ }
- replace := func(s string) string { return strings.Replace(s, ".", "_", -1) }
-
- for i, pro := range c.Provider {
- if pro.Directory == "" {
- pro.Directory = acme.LE1
+ for i, acc := range c.Account {
+ if acc.KeySize == 0 {
+ acc.KeySize = c.KeySize
}
- c.Provider[i] = pro
- for i, acc := range pro.Account {
- if acc.KeySize == 0 {
- acc.KeySize = c.KeySize
+ if acc.Mail == "" {
+ return nil, errNoMail
+ }
+ if acc.KeyFile == "" {
+ return nil, errNoKey
+ }
+ if c.BaseDir != "" {
+ acc.KeyFile = path.Join(c.BaseDir, acc.KeyFile)
+ }
+ c.Account[i] = acc
+ for i, dom := range acc.Domain {
+ if dom.Gracetime != 0 {
+ dom.Gracetime = c.Gracetime
}
- if acc.Mail == "" {
- return nil, errNoMail
+ if dom.KeySize == 0 {
+ dom.KeySize = c.KeySize
}
- if acc.KeyFile == "" {
- return nil, errNoKey
+ if len(dom.Altnames) == 0 {
+ return nil, errNoAltNames
}
- if c.BaseDir != "" {
- acc.KeyFile = path.Join(c.BaseDir, acc.KeyFile)
+ dom.Altnames = checkWWW(dom.Altnames)
+ d := dom.Altnames[0]
+ if dom.KeyFile == "" {
+ dom.KeyFile = path.Join(keyPath, d+".key")
+ }
+ if dom.CrtFile == "" {
+ dom.CrtFile = path.Join(crtPath, d+".pem")
}
- pro.Account[i] = acc
- for i, dom := range acc.Domain {
- if dom.Gracetime != 0 {
- dom.Gracetime = c.Gracetime
- }
- if dom.KeySize == 0 {
- dom.KeySize = c.KeySize
- }
- if len(dom.Altnames) == 0 {
- return nil, errNoAltNames
- }
- dom.Altnames = checkWWW(dom.Altnames)
- d := dom.Altnames[0]
- if dom.KeyFile == "" {
- dom.KeyFile = path.Join(keyPath, replace(d)+".key")
- }
- if dom.CrtFile == "" {
- dom.CrtFile = path.Join(crtPath, replace(d)+".pem")
- }
- if c.BaseDir != "" {
- dom.KeyFile = path.Join(c.BaseDir, dom.KeyFile)
- dom.CrtFile = path.Join(c.BaseDir, dom.CrtFile)
- }
- acc.Domain[i] = dom
+ if c.BaseDir != "" {
+ dom.KeyFile = path.Join(c.BaseDir, dom.KeyFile)
+ dom.CrtFile = path.Join(c.BaseDir, dom.CrtFile)
}
+ acc.Domain[i] = dom
}
}