From 8ce6e8dd325c658b3ca49a5de6c7540a72ec3fb5 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 18 Dec 2015 19:00:12 +0100 Subject: Expand interface --- cmd/acme/config.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'cmd/acme/config.go') 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 } -- cgit v1.2.3