name.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. PricingModelPipelineName string = "pricingmodel"
  20. )
  21. var nameByType map[string]string
  22. // initializes the package, creates type -> pipeline mapping
  23. func init() {
  24. allocSetKey := typeutil.TypeOf[opencost.AllocationSet]()
  25. allocKey := typeutil.TypeOf[opencost.Allocation]()
  26. assetSetKey := typeutil.TypeOf[opencost.AssetSet]()
  27. assetKey := typeutil.TypeOf[opencost.Asset]()
  28. cloudCostsSetKey := typeutil.TypeOf[opencost.CloudCostSet]()
  29. cloudCostKey := typeutil.TypeOf[opencost.CloudCost]()
  30. networkInsightSetKey := typeutil.TypeOf[opencost.NetworkInsightSet]()
  31. networkInsightKey := typeutil.TypeOf[opencost.NetworkInsight]()
  32. heartbeatKey := typeutil.TypeOf[heartbeat.Heartbeat]()
  33. diagnosticsKey := typeutil.TypeOf[diagnostics.DiagnosticsRunReport]()
  34. kubeModelSetKey := typeutil.TypeOf[kubemodel.KubeModelSet]()
  35. nameByType = map[string]string{
  36. allocSetKey: AllocationPipelineName,
  37. allocKey: AllocationPipelineName,
  38. assetSetKey: AssetsPipelineName,
  39. assetKey: AssetsPipelineName,
  40. cloudCostsSetKey: CloudCostsPipelineName,
  41. cloudCostKey: CloudCostsPipelineName,
  42. networkInsightSetKey: NetworkInsightPipelineName,
  43. networkInsightKey: NetworkInsightPipelineName,
  44. heartbeatKey: HeartbeatPipelineName,
  45. diagnosticsKey: DiagnosticsPipelineName,
  46. kubeModelSetKey: KubeModelPipelineName,
  47. }
  48. }
  49. func NameFor[T any]() string {
  50. return nameByType[typeutil.TypeOf[T]()]
  51. }