4
0

runtime.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package configissues
  2. import (
  3. "context"
  4. health "github.com/jamesread/armature-health/v2"
  5. log "github.com/sirupsen/logrus"
  6. )
  7. // ReportRuntime records an issue discovered while OliveTin is running, rather
  8. // than from the configuration (for example, a call to a deprecated API
  9. // method). Unlike Report, runtime issues are kept when the issue list is
  10. // rebuilt on config reload or entity changes. They are cleared on restart.
  11. func ReportRuntime(issue Issue) {
  12. raise(sourceRuntime, issue)
  13. }
  14. // CopyRuntime returns a copy of the runtime issues.
  15. func CopyRuntime() []Issue {
  16. stored, err := service.ListIssues(context.Background(), false, true)
  17. if err != nil {
  18. log.WithError(err).Error("Could not list runtime issues")
  19. return []Issue{}
  20. }
  21. runtime := make([]health.IssueView, 0)
  22. for _, view := range stored {
  23. if view.CheckID == sourceRuntime {
  24. runtime = append(runtime, view)
  25. }
  26. }
  27. return orderedIssues(runtime)
  28. }
  29. // ClearRuntime removes all runtime issues. Intended for tests.
  30. func ClearRuntime() {
  31. setSource(sourceRuntime, nil)
  32. }