(ctx context.Context, rep repo.Repository)
| 23 | } |
| 24 | |
| 25 | func (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 | } |
nothing calls this directly
no test coverage detected