mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-05 21:14:56 +00:00
switch to snapshots cmd for checking repo exists
Signed-off-by: Steve Kriss <krisss@vmware.com>
This commit is contained in:
@@ -84,9 +84,9 @@ func InitCommand(repoIdentifier string) *Command {
|
||||
}
|
||||
}
|
||||
|
||||
func StatsCommand(repoIdentifier string) *Command {
|
||||
func SnapshotsCommand(repoIdentifier string) *Command {
|
||||
return &Command{
|
||||
Command: "stats",
|
||||
Command: "snapshots",
|
||||
RepoIdentifier: repoIdentifier,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,10 +96,10 @@ func TestInitCommand(t *testing.T) {
|
||||
assert.Equal(t, "repo-id", c.RepoIdentifier)
|
||||
}
|
||||
|
||||
func TestStatsCommand(t *testing.T) {
|
||||
c := StatsCommand("repo-id")
|
||||
func TestSnapshotsCommand(t *testing.T) {
|
||||
c := SnapshotsCommand("repo-id")
|
||||
|
||||
assert.Equal(t, "stats", c.Command)
|
||||
assert.Equal(t, "snapshots", c.Command)
|
||||
assert.Equal(t, "repo-id", c.RepoIdentifier)
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ type RepositoryManager interface {
|
||||
// InitRepo initializes a repo with the specified name and identifier.
|
||||
InitRepo(repo *velerov1api.ResticRepository) error
|
||||
|
||||
// ConnectToRepo runs the 'restic stats' command against the
|
||||
// ConnectToRepo runs the 'restic snapshots' command against the
|
||||
// specified repo, and returns an error if it fails. This is
|
||||
// intended to be used to ensure that the repo exists/can be
|
||||
// authenticated to.
|
||||
@@ -184,11 +184,17 @@ func (rm *repositoryManager) InitRepo(repo *velerov1api.ResticRepository) error
|
||||
}
|
||||
|
||||
func (rm *repositoryManager) ConnectToRepo(repo *velerov1api.ResticRepository) error {
|
||||
// restic stats requires a non-exclusive lock
|
||||
// restic snapshots requires a non-exclusive lock
|
||||
rm.repoLocker.Lock(repo.Name)
|
||||
defer rm.repoLocker.Unlock(repo.Name)
|
||||
|
||||
return rm.exec(StatsCommand(repo.Spec.ResticIdentifier), repo.Spec.BackupStorageLocation)
|
||||
snapshotsCmd := SnapshotsCommand(repo.Spec.ResticIdentifier)
|
||||
// use the '--last' flag to minimize the amount of data fetched since
|
||||
// we're just validating that the repo exists and can be authenticated
|
||||
// to.
|
||||
snapshotsCmd.ExtraFlags = append(snapshotsCmd.ExtraFlags, "--last")
|
||||
|
||||
return rm.exec(snapshotsCmd, repo.Spec.BackupStorageLocation)
|
||||
}
|
||||
|
||||
func (rm *repositoryManager) CheckRepo(repo *velerov1api.ResticRepository) error {
|
||||
|
||||
Reference in New Issue
Block a user