aboutsummaryrefslogtreecommitdiff
path: root/cmd/acme/config.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-18 19:00:12 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-18 19:00:12 +0100
commit8ce6e8dd325c658b3ca49a5de6c7540a72ec3fb5 (patch)
tree8fbc4b4c4f2405b9ce82e72ef7ed27c487dc9b28 /cmd/acme/config.go
parent6d1eef0c011cbe666300ee023ccdbeac80dc43c0 (diff)
Expand interface
Diffstat (limited to 'cmd/acme/config.go')
-rw-r--r--cmd/acme/config.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd/acme/config.go b/cmd/acme/config.go
index 7ed5bcb..d9d6200 100644
--- a/cmd/acme/config.go
+++ b/cmd/acme/config.go
@@ -4,6 +4,7 @@ import (
"crypto/rsa"
"crypto/x509"
"errors"
+ "os"
"path"
"strings"
"time"
@@ -141,17 +142,30 @@ func LoadConfig(fname string) (*Config, error) {
type PrivKey interface {
KeyPath() string
Size() int
+ KeyExists() bool
}
type Cert interface {
CertPath() string
+ CertExists() bool
+}
+
+func exists(fname string) bool {
+ if _, err := os.Stat(fname); os.IsNotExist(err) {
+ return false
+ }
+ return true
}
func (d desire) CertPath() string { return d.Cert }
func (d desire) KeyPath() string { return d.Key }
func (d desire) Size() int { return d.KeySize }
+func (d desire) KeyExists() bool { return exists(d.Key) }
+func (d desire) CertExists() bool { return exists(d.Cert) }
+
func (a account) KeyPath() string { return a.Key }
func (a account) Size() int { return a.KeySize }
+func (a account) KeyExists() bool { return exists(a.Key) }
type duration struct{ time.Duration }