mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
refactor: changed removing secret from store returns error
This commit is contained in:
parent
17350ab99b
commit
e38402edc3
3 changed files with 11 additions and 4 deletions
|
|
@ -102,10 +102,16 @@ func (l *LocalSecretStore) ListSecrets() (map[string]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveSecretByID removes the specified secretID stored locally
|
// RemoveSecretByID removes the specified secretID stored locally
|
||||||
func (l *LocalSecretStore) RemoveSecretByID(secretID string) {
|
func (l *LocalSecretStore) RemoveSecretByID(secretID string) error {
|
||||||
l.mu.RLock()
|
l.mu.RLock()
|
||||||
|
// Let user know if there was nothing to delete
|
||||||
|
_, err := l.GetSecretByID(secretID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
delete(l.Secrets, secretID)
|
delete(l.Secrets, secretID)
|
||||||
l.mu.RUnlock()
|
l.mu.RUnlock()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// openStore tries to create or open the LocalSecretStore based on the environment
|
// openStore tries to create or open the LocalSecretStore based on the environment
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@ type SecretStore interface {
|
||||||
GetSecretByID(secretID string) (string, error)
|
GetSecretByID(secretID string) (string, error)
|
||||||
StoreSecretByID(secretID, secret string) error
|
StoreSecretByID(secretID, secret string) error
|
||||||
ListSecrets() (map[string]string, error)
|
ListSecrets() (map[string]string, error)
|
||||||
RemoveSecretByID(secretID string)
|
RemoveSecretByID(secretID string) error
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ func (s *StaticStore) ListSecrets() (map[string]string, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StaticStore) RemoveSecretByID(secretID string) {
|
func (s *StaticStore) RemoveSecretByID(secretID string) error {
|
||||||
// Nothing to do here, since nothing is being stored
|
// Nothing to do here, since nothing is being stored. With different implementations, we could return an error when no secret is found for a specific ID.
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue