mirror of
https://github.com/kopia/kopia.git
synced 2026-01-26 07:18:02 -05:00
* fixed godot linter errors * reformatted source with gofumpt * disabled some linters * fixed nolintlint warnings * fixed gci warnings * lint: fixed 'nestif' warnings * lint: fixed 'exhaustive' warnings * lint: fixed 'gocritic' warnings * lint: fixed 'noctx' warnings * lint: fixed 'wsl' warnings * lint: fixed 'goerr113' warnings * lint: fixed 'gosec' warnings * lint: upgraded linter to 1.30.0 * lint: more 'exhaustive' warnings Co-authored-by: Nick <nick@kasten.io>
34 lines
644 B
Go
34 lines
644 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"sort"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
"github.com/kopia/kopia/snapshot/policy"
|
|
)
|
|
|
|
var policyListCommand = policyCommands.Command("list", "List policies.").Alias("ls")
|
|
|
|
func init() {
|
|
policyListCommand.Action(repositoryAction(listPolicies))
|
|
}
|
|
|
|
func listPolicies(ctx context.Context, rep repo.Repository) error {
|
|
policies, err := policy.ListPolicies(ctx, rep)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
sort.Slice(policies, func(i, j int) bool {
|
|
return policies[i].Target().String() < policies[j].Target().String()
|
|
})
|
|
|
|
for _, pol := range policies {
|
|
fmt.Println(pol.ID(), pol.Target())
|
|
}
|
|
|
|
return nil
|
|
}
|