From 39d312dac6ebdb67bdb67406b879624d8f5296d2 Mon Sep 17 00:00:00 2001 From: Ying Li Date: Tue, 12 Apr 2016 21:46:03 -0700 Subject: [PATCH] While we're at cleanups, change "name" in keydbstore to be keyID to more accurately reflect what the name of the key is. Signed-off-by: Ying Li --- signer/keydbstore/keydbstore.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/signer/keydbstore/keydbstore.go b/signer/keydbstore/keydbstore.go index ebd0c49ae2..704c0de9a2 100644 --- a/signer/keydbstore/keydbstore.go +++ b/signer/keydbstore/keydbstore.go @@ -106,18 +106,18 @@ func (s *KeyDBStore) AddKey(keyInfo trustmanager.KeyInfo, privKey data.PrivateKe } // GetKey returns the PrivateKey given a KeyID -func (s *KeyDBStore) GetKey(name string) (data.PrivateKey, string, error) { +func (s *KeyDBStore) GetKey(keyID string) (data.PrivateKey, string, error) { s.Lock() defer s.Unlock() - cachedKeyEntry, ok := s.cachedKeys[name] + cachedKeyEntry, ok := s.cachedKeys[keyID] if ok { return cachedKeyEntry, "", nil } // Retrieve the GORM private key from the database dbPrivateKey := GormPrivateKey{} - if s.db.Where(&GormPrivateKey{KeyID: name}).First(&dbPrivateKey).RecordNotFound() { - return nil, "", trustmanager.ErrKeyNotFound{KeyID: name} + if s.db.Where(&GormPrivateKey{KeyID: keyID}).First(&dbPrivateKey).RecordNotFound() { + return nil, "", trustmanager.ErrKeyNotFound{KeyID: keyID} } // Get the passphrase to use for this key @@ -146,7 +146,7 @@ func (s *KeyDBStore) GetKey(name string) (data.PrivateKey, string, error) { } // GetKeyInfo returns the PrivateKey's role and gun in a KeyInfo given a KeyID -func (s *KeyDBStore) GetKeyInfo(name string) (trustmanager.KeyInfo, error) { +func (s *KeyDBStore) GetKeyInfo(keyID string) (trustmanager.KeyInfo, error) { return trustmanager.KeyInfo{}, fmt.Errorf("GetKeyInfo currently not supported for KeyDBStore, as it does not track roles or GUNs") } @@ -175,11 +175,11 @@ func (s *KeyDBStore) RemoveKey(keyID string) error { } // RotateKeyPassphrase rotates the key-encryption-key -func (s *KeyDBStore) RotateKeyPassphrase(name, newPassphraseAlias string) error { +func (s *KeyDBStore) RotateKeyPassphrase(keyID, newPassphraseAlias string) error { // Retrieve the GORM private key from the database dbPrivateKey := GormPrivateKey{} - if s.db.Where(&GormPrivateKey{KeyID: name}).First(&dbPrivateKey).RecordNotFound() { - return trustmanager.ErrKeyNotFound{KeyID: name} + if s.db.Where(&GormPrivateKey{KeyID: keyID}).First(&dbPrivateKey).RecordNotFound() { + return trustmanager.ErrKeyNotFound{KeyID: keyID} } // Get the current passphrase to use for this key