| 12345678910111213141516171819202122232425262728293031323334 |
- package kubemodel
- // @bingen:generate:Resource
- type Resource string
- const (
- ResourceCPU Resource = "cpu"
- ResourceMemory Resource = "memory"
- ResourceNvidia Resource = "nvidia.com/gpu"
- )
- var GPUResources = []Resource{ResourceNvidia}
- // @bingen:generate:ResourceQuantity
- type ResourceQuantity struct {
- Resource Resource `json:"resource"` // @bingen:field[version=1]
- Unit Unit `json:"unit"` // @bingen:field[version=1]
- Values Stats `json:"values"` // @bingen:field[version=1]
- }
- // @bingen:generate:ResourceQuantities
- type ResourceQuantities map[Resource]ResourceQuantity
- func (rqs ResourceQuantities) Set(resource Resource, unit Unit, statType StatType, value float64) {
- if _, ok := rqs[resource]; !ok {
- rqs[resource] = ResourceQuantity{
- Resource: resource,
- Unit: unit,
- Values: NewStats(),
- }
- }
- rqs[resource].Values[statType] = value
- }
|