MCPcopy Index your code
hub / github.com/kopia/kopia / run

Method run

cli/command_policy_ls.go:25–49  ·  view source on GitHub ↗
(ctx context.Context, rep repo.Repository)

Source from the content-addressed store, hash-verified

23}
24
25func (c *commandPolicyList) run(ctx context.Context, rep repo.Repository) error {
26 var jl jsonList
27
28 jl.begin(&c.jo)
29 defer jl.end()
30
31 policies, err := policy.ListPolicies(ctx, rep)
32 if err != nil {
33 return errors.Wrap(err, "error listing policies")
34 }
35
36 sort.Slice(policies, func(i, j int) bool {
37 return policies[i].Target().String() < policies[j].Target().String()
38 })
39
40 for _, pol := range policies {
41 if c.jo.jsonOutput {
42 jl.emit(policy.TargetWithPolicy{ID: pol.ID(), Target: pol.Target(), Policy: pol})
43 } else {
44 c.out.printStdout("%v %v\n", pol.ID(), pol.Target())
45 }
46 }
47
48 return nil
49}

Callers

nothing calls this directly

Calls 8

beginMethod · 0.95
endMethod · 0.95
emitMethod · 0.95
ListPoliciesFunction · 0.92
TargetMethod · 0.80
IDMethod · 0.80
printStdoutMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected