Skip to content

Commit

Permalink
Merge pull request containers#10206 from Luap99/fix-9837
Browse files Browse the repository at this point in the history
compat api: Networks must be empty instead of null
  • Loading branch information
openshift-merge-robot authored May 4, 2021
2 parents 5204842 + f185666 commit dea6189
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/api/handlers/compat/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/containers/podman/v3/pkg/util"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/go-connections/nat"
"github.com/docker/go-units"
"github.com/gorilla/schema"
Expand Down Expand Up @@ -526,6 +527,10 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
if err := json.Unmarshal(n, &networkSettings); err != nil {
return nil, err
}
// do not report null instead use an empty map
if networkSettings.Networks == nil {
networkSettings.Networks = map[string]*network.EndpointSettings{}
}

c := types.ContainerJSON{
ContainerJSONBase: &cb,
Expand Down
5 changes: 5 additions & 0 deletions test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,15 @@ t GET containers/$cid/json 200 \
t POST containers/create Image=$IMAGE Entrypoint='["top"]' 201 \
.Id~[0-9a-f]\\{64\\}
cid_top=$(jq -r '.Id' <<<"$output")
network_expect="{}"
if root; then
network_expect='.podman.NetworkID=podman'
fi
t GET containers/${cid_top}/json 200 \
.Config.Entrypoint[0]="top" \
.Config.Cmd='[]' \
.Path="top"
.NetworkSettings.Networks="$network_expect"
t POST containers/${cid_top}/start 204
# make sure the container is running
t GET containers/${cid_top}/json 200 \
Expand Down

0 comments on commit dea6189

Please sign in to comment.