Merge pull request #8691 from Luap99/network-compat

Fix some network compat api problems
This commit is contained in:
OpenShift Merge Robot
2020-12-11 10:04:28 -05:00
committed by GitHub
2 changed files with 10 additions and 4 deletions

View File

@ -131,7 +131,7 @@ func getNetworkResourceByNameOrID(nameOrID string, runtime *libpod.Runtime, filt
Name: conf.Name, Name: conf.Name,
ID: network.GetNetworkID(conf.Name), ID: network.GetNetworkID(conf.Name),
Created: time.Unix(int64(stat.Ctim.Sec), int64(stat.Ctim.Nsec)), // nolint: unconvert Created: time.Unix(int64(stat.Ctim.Sec), int64(stat.Ctim.Nsec)), // nolint: unconvert
Scope: "", Scope: "local",
Driver: network.DefaultNetworkDriver, Driver: network.DefaultNetworkDriver,
EnableIPv6: false, EnableIPv6: false,
IPAM: dockerNetwork.IPAM{ IPAM: dockerNetwork.IPAM{
@ -197,7 +197,7 @@ func ListNetworks(w http.ResponseWriter, r *http.Request) {
} }
var reports []*types.NetworkResource var reports []*types.NetworkResource
logrus.Errorf("netNames: %q", strings.Join(netNames, ", ")) logrus.Debugf("netNames: %q", strings.Join(netNames, ", "))
for _, name := range netNames { for _, name := range netNames {
report, err := getNetworkResourceByNameOrID(name, runtime, query.Filters) report, err := getNetworkResourceByNameOrID(name, runtime, query.Filters)
if err != nil { if err != nil {
@ -239,7 +239,7 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) {
Internal: networkCreate.Internal, Internal: networkCreate.Internal,
Labels: networkCreate.Labels, Labels: networkCreate.Labels,
} }
if networkCreate.IPAM != nil && networkCreate.IPAM.Config != nil { if networkCreate.IPAM != nil && len(networkCreate.IPAM.Config) > 0 {
if len(networkCreate.IPAM.Config) > 1 { if len(networkCreate.IPAM.Config) > 1 {
utils.InternalServerError(w, errors.New("compat network create can only support one IPAM config")) utils.InternalServerError(w, errors.New("compat network create can only support one IPAM config"))
return return

View File

@ -50,7 +50,13 @@ t GET networks?filters=%7B%22dangling%22%3A%5B%221%22%5D%7D 500 \
# network inspect docker # network inspect docker
t GET networks/a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1 200 \ t GET networks/a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1 200 \
.Name=network1 \ .Name=network1 \
.Id=a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1 .Id=a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1 \
.Scope=local
# network create docker
t POST networks/create '"Name":"net3","IPAM":{"Config":[]}' 201
# network delete docker
t DELETE networks/net3 204
# clean the network # clean the network
t DELETE libpod/networks/network1 200 \ t DELETE libpod/networks/network1 200 \