node.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package pricing
  2. import (
  3. "maps"
  4. "slices"
  5. "time"
  6. "github.com/opencost/opencost/core/pkg/unit"
  7. )
  8. type NodePricingProperties struct {
  9. Provider Provider `json:"provider,omitempty" yaml:"provider,omitempty"`
  10. Region string `json:"region,omitempty" yaml:"region,omitempty"`
  11. InstanceType string `json:"instanceType,omitempty" yaml:"instanceType,omitempty"`
  12. Provisioning ProvisioningType `json:"provisioning,omitempty" yaml:"provisioning,omitempty"`
  13. Commitment CommitmentType `json:"commitment,omitempty" yaml:"commitment,omitempty"`
  14. Cluster string `json:"cluster,omitempty" yaml:"cluster,omitempty"`
  15. ProviderID string `json:"providerID,omitempty" yaml:"providerID,omitempty"`
  16. Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
  17. Start *time.Time `json:"start,omitempty" yaml:"start,omitempty"`
  18. End *time.Time `json:"end,omitempty" yaml:"end,omitempty"`
  19. }
  20. type NodePricing struct {
  21. Properties NodePricingProperties `json:"properties" yaml:"properties"`
  22. Prices Prices `json:"prices" yaml:"pricing"`
  23. }
  24. func (np *NodePricing) GetCurrencies() []unit.Currency {
  25. currencies := map[unit.Currency]struct{}{}
  26. for currency := range np.Prices {
  27. currencies[currency] = struct{}{}
  28. }
  29. return slices.Collect(maps.Keys(currencies))
  30. }