Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #42 from everpeace/omitempty-in-map-fields-in-status
Browse files Browse the repository at this point in the history
map fields specifiy omitempty to prevent output "null" value
  • Loading branch information
everpeace authored Nov 16, 2021
2 parents 908bd6d + d7bbfd0 commit 09c1310
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 10 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ spec:
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity)
pairs.
nullable: true
type: object
type: object
required:
Expand All @@ -155,6 +156,7 @@ spec:
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity)
pairs.
nullable: true
type: object
type: object
throttlerName:
Expand Down Expand Up @@ -190,6 +192,7 @@ spec:
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity)
pairs.
nullable: true
type: object
type: object
required:
Expand All @@ -206,6 +209,7 @@ spec:
resourceRequests:
additionalProperties:
type: boolean
nullable: true
type: object
type: object
used:
Expand All @@ -224,6 +228,7 @@ spec:
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity)
pairs.
nullable: true
type: object
type: object
type: object
Expand Down Expand Up @@ -421,6 +426,7 @@ spec:
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity)
pairs.
nullable: true
type: object
type: object
required:
Expand All @@ -443,6 +449,7 @@ spec:
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity)
pairs.
nullable: true
type: object
type: object
throttlerName:
Expand Down Expand Up @@ -478,6 +485,7 @@ spec:
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity)
pairs.
nullable: true
type: object
type: object
required:
Expand All @@ -494,6 +502,7 @@ spec:
resourceRequests:
additionalProperties:
type: boolean
nullable: true
type: object
type: object
used:
Expand All @@ -512,6 +521,7 @@ spec:
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity)
pairs.
nullable: true
type: object
type: object
type: object
Expand Down
12 changes: 8 additions & 4 deletions pkg/apis/schedule/v1alpha1/resource_amount.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@ import (
)

type ResourceAmount struct {
ResourceCounts *ResourceCounts `json:"resourceCounts,omitempty"`
ResourceRequests corev1.ResourceList `json:"resourceRequests"`
ResourceCounts *ResourceCounts `json:"resourceCounts,omitempty"`

//+nullable
ResourceRequests corev1.ResourceList `json:"resourceRequests,omitempty"`
}

type ResourceCounts struct {
Pod int `json:"pod"`
}

type IsResourceAmountThrottled struct {
ResourceCounts IsResourceCountThrottled `json:"resourceCounts"`
ResourceRequests map[corev1.ResourceName]bool `json:"resourceRequests"`
ResourceCounts IsResourceCountThrottled `json:"resourceCounts"`

//+nullable
ResourceRequests map[corev1.ResourceName]bool `json:"resourceRequests,omitempty"`
}

func (t IsResourceAmountThrottled) IsThrottledFor(pod *corev1.Pod) bool {
Expand Down

0 comments on commit 09c1310

Please sign in to comment.