name.go 2.4 KB

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