Skip to content

Commit

Permalink
fix(api-server): empty list instead of null (#7780)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <[email protected]>
  • Loading branch information
jakubdyszkiewicz authored Sep 18, 2023
1 parent 8236a62 commit 88d07ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/api-server/inspect_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,9 @@ func inspectRulesAttachment(cfg *kuma_cp.Config, builder xds_context.MeshContext
return
}
rulesAttachments := inspect.BuildRulesAttachments(matchedPolicies.Dynamic, proxy.Dataplane.Spec.Networking, meshContext.VIPDomains)
resp := api_server_types.RuleInspectResponse{}
resp := api_server_types.RuleInspectResponse{
Items: []api_server_types.RuleInspectEntry{},
}
for _, ruleAttachment := range rulesAttachments {
subset := map[string]string{}
for _, tag := range ruleAttachment.Rule.Subset {
Expand Down
9 changes: 9 additions & 0 deletions pkg/api-server/inspect_endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,15 @@ var _ = Describe("Inspect WS", func() {
},
contentType: "text/plain",
}),
Entry("inspect rules empty", testCase{
path: "/meshes/default/dataplanes/web-01/rules",
matcher: matchers.MatchGoldenJSON(path.Join("testdata", "inspect_dataplane_rules_empty.golden.json")),
resources: []core_model.Resource{
samples2.MeshDefault(),
samples2.DataplaneWeb(),
},
contentType: restful.MIME_JSON,
}),
Entry("inspect rules basic", testCase{
path: "/meshes/default/dataplanes/web-01/rules",
matcher: matchers.MatchGoldenJSON(path.Join("testdata", "inspect_dataplane_rules.golden.json")),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"total": 0,
"items": []
}

0 comments on commit 88d07ef

Please sign in to comment.