window.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package filter
  2. //
  3. //import (
  4. // "fmt"
  5. // "github.com/opencost/opencost/pkg/kubecost"
  6. // "github.com/opencost/opencost/pkg/log"
  7. //)
  8. //
  9. //type Windowed interface {
  10. // GetWindow() kubecost.Window
  11. //}
  12. //
  13. //// WindowOperation are operations that can be performed on types that have windows
  14. //type WindowOperation string
  15. //
  16. //const (
  17. // WindowContains WindowOperation = "windowcontains"
  18. //)
  19. //
  20. //// WindowCondition is a filter can be used on any type that has a window and implements GetWindow()
  21. //type WindowCondition[T Windowed] struct {
  22. // Window kubecost.Window
  23. // Op WindowOperation
  24. //}
  25. //
  26. //func (wc WindowCondition[T]) String() string {
  27. // return fmt.Sprintf(`(%s "%s")`, wc.Op, wc.Window.String())
  28. //}
  29. //
  30. //func (wc WindowCondition[T]) Matches(that T) bool {
  31. // thatWindow := that.GetWindow()
  32. // switch wc.Op {
  33. // case WindowContains:
  34. // return wc.Window.ContainsWindow(thatWindow)
  35. // default:
  36. // log.Errorf("Filter: Window: Unhandled filter operation. This is a filter implementation error and requires immediate patching. Op: %s", wc.Op)
  37. // return false
  38. // }
  39. //}