mock.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package cloudcost
  2. import (
  3. "time"
  4. "github.com/opencost/opencost/pkg/kubecost"
  5. )
  6. func DefaultMockCloudCostSet(start, end time.Time, provider, integration string) *kubecost.CloudCostSet {
  7. ccs := kubecost.NewCloudCostSet(start, end)
  8. ccs.Integration = integration
  9. ccs.Insert(&kubecost.CloudCost{
  10. Window: ccs.Window,
  11. Properties: &kubecost.CloudCostProperties{
  12. Provider: provider,
  13. AccountID: "account1",
  14. InvoiceEntityID: "invoiceEntity1",
  15. Service: provider + "-storage",
  16. Category: kubecost.StorageCategory,
  17. Labels: kubecost.CloudCostLabels{
  18. "label1": "value1",
  19. "label2": "value2",
  20. "label3": "value3",
  21. },
  22. ProviderID: "id1",
  23. },
  24. ListCost: kubecost.CostMetric{
  25. Cost: 100,
  26. KubernetesPercent: 0,
  27. },
  28. NetCost: kubecost.CostMetric{
  29. Cost: 100,
  30. KubernetesPercent: 0,
  31. },
  32. })
  33. ccs.Insert(&kubecost.CloudCost{
  34. Window: ccs.Window,
  35. Properties: &kubecost.CloudCostProperties{
  36. Provider: provider,
  37. AccountID: "account1",
  38. InvoiceEntityID: "invoiceEntity1",
  39. Service: provider + "-compute",
  40. Category: kubecost.ComputeCategory,
  41. Labels: kubecost.CloudCostLabels{
  42. "label1": "value1",
  43. "label2": "value2",
  44. "label3": "value3",
  45. },
  46. ProviderID: "id2",
  47. },
  48. ListCost: kubecost.CostMetric{
  49. Cost: 2000,
  50. KubernetesPercent: 1,
  51. },
  52. NetCost: kubecost.CostMetric{
  53. Cost: 1800,
  54. KubernetesPercent: 1,
  55. },
  56. })
  57. ccs.Insert(&kubecost.CloudCost{
  58. Window: ccs.Window,
  59. Properties: &kubecost.CloudCostProperties{
  60. Provider: provider,
  61. AccountID: "account2",
  62. InvoiceEntityID: "invoiceEntity2",
  63. Service: provider + "-compute",
  64. Category: kubecost.ComputeCategory,
  65. Labels: kubecost.CloudCostLabels{
  66. "label1": "value1",
  67. "label2": "value2",
  68. "label3": "value3",
  69. },
  70. ProviderID: "id3",
  71. },
  72. ListCost: kubecost.CostMetric{
  73. Cost: 8000,
  74. KubernetesPercent: 1,
  75. },
  76. NetCost: kubecost.CostMetric{
  77. Cost: 8000,
  78. KubernetesPercent: 1,
  79. },
  80. })
  81. return ccs
  82. }