Fix bug causing empty lists to return as null in GetAll/List endpoints (#286)

Fixes #285
This commit is contained in:
Zachary Wasserman 2016-10-06 09:24:12 -07:00 committed by GitHub
parent 7221aac50f
commit 1cce02cf86
5 changed files with 6 additions and 5 deletions

View File

@ -62,7 +62,8 @@ func makeListInvitesEndpoint(svc kolide.Service) endpoint.Endpoint {
if err != nil {
return listInvitesResponse{Err: err}, nil
}
var resp listInvitesResponse
resp := listInvitesResponse{Invites: []inviteResponse{}}
for _, invite := range invites {
resp.Invites = append(resp.Invites, inviteResponse{
ID: invite.ID,

View File

@ -55,7 +55,7 @@ func makeGetAllLabelsEndpoint(svc kolide.Service) endpoint.Endpoint {
if err != nil {
return getAllLabelsResponse{Err: err}, nil
}
var resp getAllLabelsResponse
resp := getAllLabelsResponse{Labels: []getLabelResponse{}}
for _, label := range labels {
resp.Labels = append(resp.Labels, getLabelResponse{
ID: label.ID,

View File

@ -55,7 +55,7 @@ func makeGetAllPacksEndpoint(svc kolide.Service) endpoint.Endpoint {
if err != nil {
return getPackResponse{Err: err}, nil
}
var resp getAllPacksResponse
resp := getAllPacksResponse{Packs: []getPackResponse{}}
for _, pack := range packs {
resp.Packs = append(resp.Packs, getPackResponse{
ID: pack.ID,

View File

@ -65,7 +65,7 @@ func makeGetAllQueriesEndpoint(svc kolide.Service) endpoint.Endpoint {
if err != nil {
return getAllQueriesResponse{Err: err}, nil
}
var resp getAllQueriesResponse
resp := getAllQueriesResponse{Queries: []getQueryResponse{}}
for _, query := range queries {
resp.Queries = append(resp.Queries, getQueryResponse{
ID: query.ID,

View File

@ -129,7 +129,7 @@ func makeListUsersEndpoint(svc kolide.Service) endpoint.Endpoint {
return listUsersResponse{Err: err}, nil
}
var resp listUsersResponse
resp := listUsersResponse{Users: []getUserResponse{}}
for _, user := range users {
resp.Users = append(resp.Users, getUserResponse{
ID: user.ID,