(ctx context.Context, rep repo.Repository)
| 31 | } |
| 32 | |
| 33 | func (c *commandNotificationProfileList) run(ctx context.Context, rep repo.Repository) error { |
| 34 | var jl jsonList |
| 35 | |
| 36 | if c.jo.jsonOutput { |
| 37 | jl.begin(&c.jo) |
| 38 | defer jl.end() |
| 39 | } |
| 40 | |
| 41 | profileConfigs, err := notifyprofile.ListProfiles(ctx, rep) |
| 42 | if err != nil { |
| 43 | return errors.Wrap(err, "unable to list notification profiles") |
| 44 | } |
| 45 | |
| 46 | for i, pc := range profileConfigs { |
| 47 | summ := getProfileSummary(ctx, pc) |
| 48 | |
| 49 | if c.jo.jsonOutput { |
| 50 | if c.raw { |
| 51 | jl.emit(pc) |
| 52 | } else { |
| 53 | jl.emit(summ) |
| 54 | } |
| 55 | } else { |
| 56 | if i > 0 { |
| 57 | c.out.printStdout("\n") |
| 58 | } |
| 59 | |
| 60 | c.out.printStdout("Profile %q Type %q Minimum Severity: %v\n %v\n", |
| 61 | summ.ProfileName, |
| 62 | pc.MethodConfig.Type, |
| 63 | notification.SeverityToString[pc.MinSeverity], |
| 64 | summ.Summary) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | return nil |
| 69 | } |
| 70 | |
| 71 | func getProfileSummary(ctx context.Context, pc notifyprofile.Config) notifyprofile.Summary { |
| 72 | var summ notifyprofile.Summary |
nothing calls this directly
no test coverage detected