From 2593495311d57007fac382cb7a6667e8f1f6b58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Sun, 14 May 2017 21:02:01 +0900 Subject: [PATCH] Document exported symbols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Michael Muré --- core/commands/keystore.go | 1 + keystore/keystore.go | 10 ++++++++++ keystore/memkeystore.go | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/core/commands/keystore.go b/core/commands/keystore.go index e0d9b5d10..522552815 100644 --- a/core/commands/keystore.go +++ b/core/commands/keystore.go @@ -49,6 +49,7 @@ type KeyOutputList struct { Keys []KeyOutput } +// KeyRenameOutput define the output type of keyRenameCmd type KeyRenameOutput struct { Was string Now string diff --git a/keystore/keystore.go b/keystore/keystore.go index e38211480..8424dbafa 100644 --- a/keystore/keystore.go +++ b/keystore/keystore.go @@ -11,10 +11,15 @@ import ( ) type Keystore interface { + // Has return whether or not a key exist in the Keystore Has(string) (bool, error) + // Put store a key in the Keystore Put(string, ci.PrivKey) error + // Get retrieve a key from the Keystore Get(string) (ci.PrivKey, error) + // Delete remove a key from the Keystore Delete(string) error + // List return a list of key identifier List() ([]string, error) } @@ -55,6 +60,7 @@ func NewFSKeystore(dir string) (*FSKeystore, error) { return &FSKeystore{dir}, nil } +// Has return whether or not a key exist in the Keystore func (ks *FSKeystore) Has(name string) (bool, error) { kp := filepath.Join(ks.dir, name) @@ -71,6 +77,7 @@ func (ks *FSKeystore) Has(name string) (bool, error) { return true, nil } +// Put store a key in the Keystore func (ks *FSKeystore) Put(name string, k ci.PrivKey) error { if err := validateName(name); err != nil { return err @@ -104,6 +111,7 @@ func (ks *FSKeystore) Put(name string, k ci.PrivKey) error { return nil } +// Get retrieve a key from the Keystore func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) { if err := validateName(name); err != nil { return nil, err @@ -122,6 +130,7 @@ func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) { return ci.UnmarshalPrivateKey(data) } +// Delete remove a key from the Keystore func (ks *FSKeystore) Delete(name string) error { if err := validateName(name); err != nil { return err @@ -132,6 +141,7 @@ func (ks *FSKeystore) Delete(name string) error { return os.Remove(kp) } +// List return a list of key identifier func (ks *FSKeystore) List() ([]string, error) { dir, err := os.Open(ks.dir) if err != nil { diff --git a/keystore/memkeystore.go b/keystore/memkeystore.go index 626ad8bc0..068c5e189 100644 --- a/keystore/memkeystore.go +++ b/keystore/memkeystore.go @@ -10,11 +10,13 @@ func NewMemKeystore() *MemKeystore { return &MemKeystore{make(map[string]ci.PrivKey)} } +// Has return whether or not a key exist in the Keystore func (mk *MemKeystore) Has(name string) (bool, error) { _, ok := mk.keys[name] return ok, nil } +// Put store a key in the Keystore func (mk *MemKeystore) Put(name string, k ci.PrivKey) error { if err := validateName(name); err != nil { return err @@ -29,6 +31,7 @@ func (mk *MemKeystore) Put(name string, k ci.PrivKey) error { return nil } +// Get retrieve a key from the Keystore func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) { if err := validateName(name); err != nil { return nil, err @@ -42,6 +45,7 @@ func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) { return k, nil } +// Delete remove a key from the Keystore func (mk *MemKeystore) Delete(name string) error { if err := validateName(name); err != nil { return err @@ -51,6 +55,7 @@ func (mk *MemKeystore) Delete(name string) error { return nil } +// List return a list of key identifier func (mk *MemKeystore) List() ([]string, error) { out := make([]string, 0, len(mk.keys)) for k, _ := range mk.keys {