name.go 2.1 KB

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