Skip to content

Commit

Permalink
Remove unused Restic related stuff. (#2418)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
e-sumin and mergify[bot] authored Oct 26, 2023
1 parent b909ad0 commit 1003ad9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 57 deletions.
41 changes: 0 additions & 41 deletions pkg/restic/restic.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ func shCommand(command string) []string {
return []string{"bash", "-o", "errexit", "-o", "pipefail", "-c", command}
}

// BackupCommandByID returns restic backup command
func BackupCommandByID(profile *param.Profile, repository, pathToBackup, encryptionKey string) ([]string, error) {
cmd, err := resticArgs(profile, repository, encryptionKey)
if err != nil {
return nil, err
}
cmd = append(cmd, "backup", pathToBackup)
command := strings.Join(cmd, " ")
return shCommand(command), nil
}

// BackupCommandByTag returns restic backup command with tag
func BackupCommandByTag(profile *param.Profile, repository, backupTag, includePath, encryptionKey string) ([]string, error) {
cmd, err := resticArgs(profile, repository, encryptionKey)
Expand Down Expand Up @@ -134,17 +123,6 @@ func InitCommand(profile *param.Profile, repository, encryptionKey string) ([]st
return shCommand(command), nil
}

// ForgetCommandByTag returns restic forget command
func ForgetCommandByTag(profile *param.Profile, repository, tag, encryptionKey string) ([]string, error) {
cmd, err := resticArgs(profile, repository, encryptionKey)
if err != nil {
return nil, err
}
cmd = append(cmd, "forget", "--tag", tag)
command := strings.Join(cmd, " ")
return shCommand(command), nil
}

// ForgetCommandByID returns restic forget command
func ForgetCommandByID(profile *param.Profile, repository, id, encryptionKey string) ([]string, error) {
cmd, err := resticArgs(profile, repository, encryptionKey)
Expand Down Expand Up @@ -449,25 +427,6 @@ func DoesRepoExist(output string) bool {
return strings.Contains(output, "Is there a repository at the following location?")
}

// SnapshotIDFromSnapshotLog gets the SnapshotID from Snapshot Command log
func SnapshotIDsFromSnapshotCommand(output string) ([]string, error) {
var snapIds []string
var result []map[string]interface{}
err := json.Unmarshal([]byte(output), &result)
if err != nil {
return nil, errors.WithMessage(err, "Failed to unmarshall output from snapshotCommand")
}
if len(result) == 0 {
return nil, errors.New("Snapshots not found")
}
for _, r := range result {
if r["short_id"] != nil {
snapIds = append(snapIds, r["short_id"].(string))
}
}
return snapIds, nil
}

// SpaceFreedFromPruneLog gets the space freed from the prune log output
// For reference, here is the logging command from restic codebase:
//
Expand Down
16 changes: 0 additions & 16 deletions pkg/restic/restic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,22 +318,6 @@ func (s *ResticDataSuite) TestGetSnapshotStatsModeFromStatsLog(c *C) {
}
}

func (s *ResticDataSuite) TestGetSnapshotIDsFromSnapshotCommand(c *C) {
for _, tc := range []struct {
log string
expected []string
checker Checker
}{
{log: `[{"time":"2019-03-28T17:35:15.146526-07:00","hostname":"MacBook-Pro.local","username":"abc","uid":501,"gid":20,"tags":["backup123"],"id":"7c0bfeb93dd5b390a6eaf8a386ec8cb86e4631f2d96400407b529b53d979536a","short_id":"7c0bfeb9"}]`, expected: []string{"7c0bfeb9"}, checker: IsNil},
{log: `[{"time":"2019-03-28T17:35:15.146526-07:00","hostname":"MacBook-Pro.local","username":"abc","uid":501,"gid":20,"tags":["backup123"],"id":"7c0bfeb93dd5b390a6eaf8a386ec8cb86e4631f2d96400407b529b53d979536a","short_id":"7c0bfeb67"},{"time":"2019-03-28T17:35:15.146526-07:00","hostname":"MacBook-Pro.local","username":"abc","uid":501,"gid":20,"tags":["backup123"],"id":"7c0bfeb93dd5b390a6eaf8a386ec8cb86e4631f2d96400407b529b53d979536a","short_id":"7c0bfeb9"}]`, expected: []string{"7c0bfeb67", "7c0bfeb9"}, checker: IsNil},
{log: `null`, expected: []string(nil), checker: NotNil},
} {
ids, err := SnapshotIDsFromSnapshotCommand(tc.log)
c.Assert(err, tc.checker)
c.Assert(ids, DeepEquals, tc.expected)
}
}

func (s *ResticDataSuite) TestIsPasswordIncorrect(c *C) {
for _, tc := range []struct {
log string
Expand Down

0 comments on commit 1003ad9

Please sign in to comment.