Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compat networks endpoint for a empty result #9295

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/api/handlers/compat/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func ListNetworks(w http.ResponseWriter, r *http.Request) {
return
}

var reports []*types.NetworkResource
reports := []*types.NetworkResource{}
logrus.Debugf("netNames: %q", strings.Join(netNames, ", "))
for _, name := range netNames {
report, err := getNetworkResourceByNameOrID(name, runtime, query.Filters)
Expand Down
3 changes: 3 additions & 0 deletions test/apiv2/35-networks.at
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ length=1 \
# invalid filter filters={"dangling":["1"]}
t GET networks?filters=%7B%22dangling%22%3A%5B%221%22%5D%7D 500 \
.cause='invalid filter "dangling"'
# (#9293 with no networks the endpoint should return empty array instead of null)
t GET networks?filters=%7B%22name%22%3A%5B%22doesnotexists%22%5D%7D 200 \
"[]"

# network inspect docker
t GET networks/a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1 200 \
Expand Down