mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
Merge pull request #10206 from Luap99/fix-9837
compat api: Networks must be empty instead of null
This commit is contained in:
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/containers/podman/v3/pkg/util"
|
"github.com/containers/podman/v3/pkg/util"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
"github.com/gorilla/schema"
|
"github.com/gorilla/schema"
|
||||||
@ -526,6 +527,10 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
|
|||||||
if err := json.Unmarshal(n, &networkSettings); err != nil {
|
if err := json.Unmarshal(n, &networkSettings); err != nil {
|
||||||
return nil, err
|
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{
|
c := types.ContainerJSON{
|
||||||
ContainerJSONBase: &cb,
|
ContainerJSONBase: &cb,
|
||||||
|
@ -205,10 +205,15 @@ t GET containers/$cid/json 200 \
|
|||||||
t POST containers/create Image=$IMAGE Entrypoint='["top"]' 201 \
|
t POST containers/create Image=$IMAGE Entrypoint='["top"]' 201 \
|
||||||
.Id~[0-9a-f]\\{64\\}
|
.Id~[0-9a-f]\\{64\\}
|
||||||
cid_top=$(jq -r '.Id' <<<"$output")
|
cid_top=$(jq -r '.Id' <<<"$output")
|
||||||
|
network_expect="{}"
|
||||||
|
if root; then
|
||||||
|
network_expect='.podman.NetworkID=podman'
|
||||||
|
fi
|
||||||
t GET containers/${cid_top}/json 200 \
|
t GET containers/${cid_top}/json 200 \
|
||||||
.Config.Entrypoint[0]="top" \
|
.Config.Entrypoint[0]="top" \
|
||||||
.Config.Cmd='[]' \
|
.Config.Cmd='[]' \
|
||||||
.Path="top"
|
.Path="top"
|
||||||
|
.NetworkSettings.Networks="$network_expect"
|
||||||
t POST containers/${cid_top}/start 204
|
t POST containers/${cid_top}/start 204
|
||||||
# make sure the container is running
|
# make sure the container is running
|
||||||
t GET containers/${cid_top}/json 200 \
|
t GET containers/${cid_top}/json 200 \
|
||||||
|
Reference in New Issue
Block a user