name.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package pipelines
  2. import (
  3. "github.com/opencost/opencost/core/pkg/diagnostics"
  4. "github.com/opencost/opencost/core/pkg/heartbeat"
  5. "github.com/opencost/opencost/core/pkg/opencost"
  6. "github.com/opencost/opencost/core/pkg/util/typeutil"
  7. )
  8. const (
  9. AllocationPipelineName string = "allocations"
  10. AssetsPipelineName string = "assets"
  11. CloudCostsPipelineName string = "cloudcosts"
  12. NetworkInsightPipelineName string = "networkinsights"
  13. CustomCostsPipelineName string = "customcosts"
  14. TurbonomicActionsPipelineName string = "turbonomicactions"
  15. HeartbeatPipelineName string = "heartbeat"
  16. DiagnosticsPipelineName string = "diagnostics"
  17. )
  18. var nameByType map[string]string
  19. // initializes the package, creates type -> pipeline mapping
  20. func init() {
  21. allocSetKey := typeutil.TypeOf[opencost.AllocationSet]()
  22. allocKey := typeutil.TypeOf[opencost.Allocation]()
  23. assetSetKey := typeutil.TypeOf[opencost.AssetSet]()
  24. assetKey := typeutil.TypeOf[opencost.Asset]()
  25. cloudCostsSetKey := typeutil.TypeOf[opencost.CloudCostSet]()
  26. cloudCostKey := typeutil.TypeOf[opencost.CloudCost]()
  27. networkInsightSetKey := typeutil.TypeOf[opencost.NetworkInsightSet]()
  28. networkInsightKey := typeutil.TypeOf[opencost.NetworkInsight]()
  29. heartbeatKey := typeutil.TypeOf[heartbeat.Heartbeat]()
  30. diagnosticsKey := typeutil.TypeOf[diagnostics.DiagnosticsRunReport]()
  31. nameByType = map[string]string{
  32. allocSetKey: AllocationPipelineName,
  33. allocKey: AllocationPipelineName,
  34. assetSetKey: AssetsPipelineName,
  35. assetKey: AssetsPipelineName,
  36. cloudCostsSetKey: CloudCostsPipelineName,
  37. cloudCostKey: CloudCostsPipelineName,
  38. networkInsightSetKey: NetworkInsightPipelineName,
  39. networkInsightKey: NetworkInsightPipelineName,
  40. heartbeatKey: HeartbeatPipelineName,
  41. diagnosticsKey: DiagnosticsPipelineName,
  42. }
  43. }
  44. func NameFor[T any]() string {
  45. return nameByType[typeutil.TypeOf[T]()]
  46. }