http: list results are never null

This commit is contained in:
Armon Dadgar
2015-09-07 10:03:10 -07:00
parent b566efd781
commit e5c7effaa9
4 changed files with 24 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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
}
@@ -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
}

View File

@@ -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
}
@@ -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
}
@@ -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
}

View File

@@ -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
}
@@ -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
}