mirror of
https://github.com/kopia/kopia.git
synced 2025-12-23 22:57:50 -05:00
* introduced passwordpersist package which has password persistence strategies (keyring, file, none, multiple) with possibility of adding more in the future. * moved all password persistence logic out of 'repo' * removed global variable repo.EnableKeyRing
35 lines
834 B
Go
35 lines
834 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
)
|
|
|
|
type commandRepositoryDisconnect struct {
|
|
svc advancedAppServices
|
|
}
|
|
|
|
func (c *commandRepositoryDisconnect) setup(svc advancedAppServices, parent commandParent) {
|
|
cmd := parent.Command("disconnect", "Disconnect from a repository.")
|
|
cmd.Action(svc.noRepositoryAction(c.run))
|
|
|
|
c.svc = svc
|
|
}
|
|
|
|
func (c *commandRepositoryDisconnect) run(ctx context.Context) error {
|
|
c.svc.removeUpdateState()
|
|
|
|
if err := repo.Disconnect(ctx, c.svc.repositoryConfigFileName()); err != nil {
|
|
return errors.Wrap(err, "unable to disconnect from repository")
|
|
}
|
|
|
|
if err := c.svc.passwordPersistenceStrategy().DeletePassword(ctx, c.svc.repositoryConfigFileName()); err != nil {
|
|
return errors.Wrap(err, "unable to remove persisted password")
|
|
}
|
|
|
|
return nil
|
|
}
|