types.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package otc
  2. import (
  3. "sync"
  4. "github.com/opencost/opencost/core/pkg/clustercache"
  5. "github.com/opencost/opencost/pkg/cloud/models"
  6. )
  7. type OTCStats struct {
  8. CurrentPage int `json:"currentPage"`
  9. MaxPages int `json:"maxPages"`
  10. RecordsPerPage int `json:"recordsPerPage"`
  11. }
  12. type Product struct {
  13. ProductIdParameter string `json:"productIdParameter"`
  14. OpiFlavour string `json:"opiFlavour"`
  15. OsUnit string `json:"osUnit,omitempty"`
  16. PriceAmount string `json:"priceAmount"`
  17. VCpu string `json:"vCpu,omitempty"`
  18. Ram string `json:"ram,omitempty"`
  19. }
  20. // OTC node pricing attributes
  21. type OTCNodeAttributes struct {
  22. Type string // like s2.large.1
  23. OS string // like windows
  24. Price string // (in EUR) like 0.023
  25. RAM string // (in GB) like 2
  26. VCPU string // like 8
  27. }
  28. type OTCPVAttributes struct {
  29. Type string // like vss.ssd
  30. Price string // (in EUR/GB/h) like 0.01
  31. }
  32. // OTC pricing is either for a node, a persistent volume (or a database, network, cluster, ...)
  33. type OTCPricing struct {
  34. NodeAttributes *OTCNodeAttributes
  35. PVAttributes *OTCPVAttributes
  36. }
  37. // the main provider struct
  38. type OTC struct {
  39. Clientset clustercache.ClusterCache
  40. Pricing map[string]*OTCPricing
  41. Config models.ProviderConfig
  42. ClusterRegion string
  43. projectID string
  44. clusterManagementPrice float64
  45. BaseCPUPrice string
  46. BaseRAMPrice string
  47. BaseGPUPrice string
  48. ValidPricingKeys map[string]bool
  49. DownloadPricingDataLock sync.RWMutex
  50. }