mirror of
https://github.com/containers/podman.git
synced 2025-06-24 11:28:24 +08:00
Merge pull request #17594 from Luap99/compat-network-create
compat API: network create return 409 for duplicate
This commit is contained in:
@ -280,10 +280,17 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) {
|
|||||||
// FIXME can we use the IPAM driver and options?
|
// FIXME can we use the IPAM driver and options?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opts := nettypes.NetworkCreateOptions{
|
||||||
|
IgnoreIfExists: !networkCreate.CheckDuplicate,
|
||||||
|
}
|
||||||
ic := abi.ContainerEngine{Libpod: runtime}
|
ic := abi.ContainerEngine{Libpod: runtime}
|
||||||
newNetwork, err := ic.NetworkCreate(r.Context(), network, nil)
|
newNetwork, err := ic.NetworkCreate(r.Context(), network, &opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.InternalServerError(w, err)
|
if errors.Is(err, nettypes.ErrNetworkExists) {
|
||||||
|
utils.Error(w, http.StatusConflict, err)
|
||||||
|
} else {
|
||||||
|
utils.InternalServerError(w, err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,9 @@ t GET networks/podman 200 \
|
|||||||
|
|
||||||
# network create docker
|
# network create docker
|
||||||
t POST networks/create Name=net3\ IPAM='{"Config":[]}' 201
|
t POST networks/create Name=net3\ IPAM='{"Config":[]}' 201
|
||||||
|
# create with same name should not error unless CheckDuplicate is set
|
||||||
|
t POST networks/create Name=net3 201
|
||||||
|
t POST networks/create Name=net3\ CheckDuplicate=true 409
|
||||||
# network delete docker
|
# network delete docker
|
||||||
t DELETE networks/net3 204
|
t DELETE networks/net3 204
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user