container.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package kubemodel
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. // @bingen:generate:Container
  7. type Container struct {
  8. PodUID string `json:"podUid"` // @bingen:field[version=1]
  9. Name string `json:"name"` // @bingen:field[version=1]
  10. Start time.Time `json:"start"` // @bingen:field[version=1]
  11. End time.Time `json:"end"` // @bingen:field[version=1]
  12. CpuMillicoreSecondsAllocated uint64 `json:"cpuMillicoreSecondsAllocated"` // @bingen:field[version=1]
  13. CpuMillicoreRequestAverageAllocated uint64 `json:"cpuMillicoreRequestAverageAllocated"` // @bingen:field[version=1]
  14. CpuMillicoreUsageAverage uint64 `json:"cpuMillicoreUsageAverage"` // @bingen:field[version=1]
  15. CpuMillicoreUsageMax uint64 `json:"cpuMillicoreUsageMax"` // @bingen:field[version=1]
  16. RAMByteSecondsAllocated uint64 `json:"ramByteSecondsAllocated"` // @bingen:field[version=1]
  17. RAMByteRequestAverageAllocated uint64 `json:"ramByteRequestAverageAllocated"` // @bingen:field[version=1]
  18. RAMByteUsageAverage uint64 `json:"ramByteUsageAverage"` // @bingen:field[version=1]
  19. RAMByteUsageMax uint64 `json:"ramByteUsageMax"` // @bingen:field[version=1]
  20. StorageByteSecondsAllocated uint64 `json:"storageByteSecondsAllocated"` // @bingen:field[version=1]
  21. StorageByteRequestAverageAllocated uint64 `json:"storageByteRequestAverageAllocated"` // @bingen:field[version=1]
  22. StorageByteUsageAverage uint64 `json:"storageByteUsageAverage"` // @bingen:field[version=1]
  23. StorageByteUsageMax uint64 `json:"storageByteUsageMax"` // @bingen:field[version=1]
  24. }
  25. func (kms *KubeModelSet) RegisterContainer(uid, name, podUID string) error {
  26. if uid == "" {
  27. err := fmt.Errorf("UID is nil for Container '%s'", name)
  28. kms.Error(err)
  29. return err
  30. }
  31. if _, ok := kms.Containers[uid]; !ok {
  32. kms.Containers[uid] = &Container{
  33. PodUID: podUID,
  34. Name: name,
  35. }
  36. kms.Metadata.ObjectCount++
  37. }
  38. return nil
  39. }