omitempty on possible null flields
This commit is contained in:
parent
e615144396
commit
b0577f3c55
@ -33,7 +33,7 @@ type PendingInformation struct {
|
|||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
Labels map[string]string `json:"labels"`
|
Labels map[string]string `json:"labels"`
|
||||||
Dependencies string `json:"dependencies"`
|
Dependencies string `json:"dependencies,omitempty"`
|
||||||
RunOn string `json:"run_on"`
|
RunOn string `json:"run_on"`
|
||||||
DepStatus string `json:"-"` // dont need those
|
DepStatus string `json:"-"` // dont need those
|
||||||
AgentId int `json:"agent_id"`
|
AgentId int `json:"agent_id"`
|
||||||
@ -48,9 +48,9 @@ type Stats struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type QueueInfo struct {
|
type QueueInfo struct {
|
||||||
Pending []PendingInformation `json:"pending"`
|
Pending []PendingInformation `json:"pending,omitempty"`
|
||||||
WaitingOnDeps string `json:"-"` // dont need those
|
WaitingOnDeps string `json:"-"` // dont need those
|
||||||
Running int `json:"running"`
|
Running int `json:"running,omitempty"`
|
||||||
Stats Stats `json:"stats"`
|
Stats Stats `json:"stats"`
|
||||||
Paused bool `json:"paused"`
|
Paused bool `json:"paused"`
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ func CheckPending(cfg *config.Config) error {
|
|||||||
return errors.New(fmt.Sprintf("Error from QueueInfo: %s", err.Error()))
|
return errors.New(fmt.Sprintf("Error from QueueInfo: %s", err.Error()))
|
||||||
}
|
}
|
||||||
if queueInfo.Stats.PendingCount > 0 {
|
if queueInfo.Stats.PendingCount > 0 {
|
||||||
|
// TODO: queueInfo.Pending may be empty
|
||||||
for _, pendingJobs := range queueInfo.Pending {
|
for _, pendingJobs := range queueInfo.Pending {
|
||||||
// TODO: separate key and value from LabelSelector and compare them deeply
|
// TODO: separate key and value from LabelSelector and compare them deeply
|
||||||
_, exists := pendingJobs.Labels[cfg.LabelSelector]
|
_, exists := pendingJobs.Labels[cfg.LabelSelector]
|
||||||
|
Loading…
Reference in New Issue
Block a user