mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
Fix bug causing empty lists to return as null in GetAll/List endpoints (#286)
Fixes #285
This commit is contained in:
parent
7221aac50f
commit
1cce02cf86
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user