repository: Introduce RemoveKey function

This replaces directly removing keys via the backend.
This commit is contained in:
Michael Eischer committed 2024-01-27 12:42:58 +01:00
1 parent 6696195f38
commit c13bf0b607
3 files changed
+22 -10

No files matched your search

+9
View File
@@ -285,6 +285,15 @@ func AddKey(ctx context.Context, s *Repository, password, username, hostname str
return newkey, nil
}
func RemoveKey(ctx context.Context, repo *Repository, id restic.ID) error {
if id == repo.KeyID() {
return errors.New("refusing to remove key currently used to access repository")
}
h := backend.Handle{Type: restic.KeyFile, Name: id.String()}
return repo.be.Remove(ctx, h)
}
func (k *Key) String() string {
if k == nil {
return "<Key nil>"