Skip to content

Commit

Permalink
http: list results are never null
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Sep 7, 2015
1 parent b566efd commit e5c7eff
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions command/agent/alloc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func (s *HTTPServer) AllocsRequest(resp http.ResponseWriter, req *http.Request)
}

setMeta(resp, &out.QueryMeta)
if out.Allocations == nil {
out.Allocations = make([]*structs.AllocListStub, 0)
}
return out.Allocations, nil
}

Expand Down
6 changes: 6 additions & 0 deletions command/agent/eval_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func (s *HTTPServer) EvalsRequest(resp http.ResponseWriter, req *http.Request) (
}

setMeta(resp, &out.QueryMeta)
if out.Evaluations == nil {
out.Evaluations = make([]*structs.Evaluation, 0)
}
return out.Evaluations, nil
}

Expand Down Expand Up @@ -55,6 +58,9 @@ func (s *HTTPServer) evalAllocations(resp http.ResponseWriter, req *http.Request
}

setMeta(resp, &out.QueryMeta)
if out.Allocations == nil {
out.Allocations = make([]*structs.AllocListStub, 0)
}
return out.Allocations, nil
}

Expand Down
9 changes: 9 additions & 0 deletions command/agent/job_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func (s *HTTPServer) jobListRequest(resp http.ResponseWriter, req *http.Request)
}

setMeta(resp, &out.QueryMeta)
if out.Jobs == nil {
out.Jobs = make([]*structs.JobListStub, 0)
}
return out.Jobs, nil
}

Expand Down Expand Up @@ -86,6 +89,9 @@ func (s *HTTPServer) jobAllocations(resp http.ResponseWriter, req *http.Request,
}

setMeta(resp, &out.QueryMeta)
if out.Allocations == nil {
out.Allocations = make([]*structs.AllocListStub, 0)
}
return out.Allocations, nil
}

Expand All @@ -107,6 +113,9 @@ func (s *HTTPServer) jobEvaluations(resp http.ResponseWriter, req *http.Request,
}

setMeta(resp, &out.QueryMeta)
if out.Evaluations == nil {
out.Evaluations = make([]*structs.Evaluation, 0)
}
return out.Evaluations, nil
}

Expand Down
6 changes: 6 additions & 0 deletions command/agent/node_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func (s *HTTPServer) NodesRequest(resp http.ResponseWriter, req *http.Request) (
}

setMeta(resp, &out.QueryMeta)
if out.Nodes == nil {
out.Nodes = make([]*structs.NodeListStub, 0)
}
return out.Nodes, nil
}

Expand Down Expand Up @@ -80,6 +83,9 @@ func (s *HTTPServer) nodeAllocations(resp http.ResponseWriter, req *http.Request
}

setMeta(resp, &out.QueryMeta)
if out.Allocs == nil {
out.Allocs = make([]*structs.Allocation, 0)
}
return out.Allocs, nil
}

Expand Down

0 comments on commit e5c7eff

Please sign in to comment.