forked from TrueCloudLab/restic
gofmt
This commit is contained in:
parent
8f9ef4402b
commit
ed30bd7b76
1 changed files with 24 additions and 20 deletions
|
@ -6,8 +6,8 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/restic"
|
|
||||||
"github.com/restic/restic/internal/errors"
|
"github.com/restic/restic/internal/errors"
|
||||||
|
"github.com/restic/restic/internal/restic"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ type ForgetOptions struct {
|
||||||
Paths []string
|
Paths []string
|
||||||
|
|
||||||
// Grouping
|
// Grouping
|
||||||
GroupBy string
|
GroupBy string
|
||||||
DryRun bool
|
DryRun bool
|
||||||
Prune bool
|
Prune bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var forgetOptions ForgetOptions
|
var forgetOptions ForgetOptions
|
||||||
|
@ -93,20 +93,24 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
|
||||||
}
|
}
|
||||||
snapshotGroups := make(map[string]restic.Snapshots)
|
snapshotGroups := make(map[string]restic.Snapshots)
|
||||||
|
|
||||||
var GroupByTag bool
|
var GroupByTag bool
|
||||||
var GroupByHost bool
|
var GroupByHost bool
|
||||||
var GroupByPath bool
|
var GroupByPath bool
|
||||||
var GroupOptionList []string
|
var GroupOptionList []string
|
||||||
|
|
||||||
GroupOptionList = strings.Split( opts.GroupBy, "," )
|
GroupOptionList = strings.Split(opts.GroupBy, ",")
|
||||||
|
|
||||||
for _, option := range GroupOptionList {
|
for _, option := range GroupOptionList {
|
||||||
switch( option ) {
|
switch option {
|
||||||
case "host": GroupByHost = true
|
case "host":
|
||||||
case "paths": GroupByPath = true
|
GroupByHost = true
|
||||||
case "tags": GroupByTag = true
|
case "paths":
|
||||||
case "":
|
GroupByPath = true
|
||||||
default: return errors.Fatal( "unknown grouping option: '" + option + "'" )
|
case "tags":
|
||||||
|
GroupByTag = true
|
||||||
|
case "":
|
||||||
|
default:
|
||||||
|
return errors.Fatal("unknown grouping option: '" + option + "'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,21 +184,21 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
Verbosef( "snapshots" )
|
Verbosef("snapshots")
|
||||||
var infoStrings []string
|
var infoStrings []string
|
||||||
if GroupByTag {
|
if GroupByTag {
|
||||||
infoStrings = append( infoStrings, "tags [" + strings.Join( key.Tags, ", " ) + "]" )
|
infoStrings = append(infoStrings, "tags ["+strings.Join(key.Tags, ", ")+"]")
|
||||||
}
|
}
|
||||||
if GroupByHost {
|
if GroupByHost {
|
||||||
infoStrings = append( infoStrings, "host [" + key.Hostname + "]" )
|
infoStrings = append(infoStrings, "host ["+key.Hostname+"]")
|
||||||
}
|
}
|
||||||
if GroupByPath {
|
if GroupByPath {
|
||||||
infoStrings = append( infoStrings, "paths [" + strings.Join( key.Paths, ", " ) + "]" )
|
infoStrings = append(infoStrings, "paths ["+strings.Join(key.Paths, ", ")+"]")
|
||||||
}
|
}
|
||||||
if infoStrings != nil {
|
if infoStrings != nil {
|
||||||
Verbosef( " for (" + strings.Join( infoStrings, ", " ) + ")" )
|
Verbosef(" for (" + strings.Join(infoStrings, ", ") + ")")
|
||||||
}
|
}
|
||||||
Verbosef( ":\n\n" )
|
Verbosef(":\n\n")
|
||||||
|
|
||||||
keep, remove := restic.ApplyPolicy(snapshotGroup, policy)
|
keep, remove := restic.ApplyPolicy(snapshotGroup, policy)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue