From 53c8bc5a5e48f02fb0c1f1a87ec5214fb47f0b93 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Fri, 4 Dec 2020 13:44:33 -0700 Subject: Jira RUN-1106 Network handlers updates * Add network API tests * Update network create endpoint to return ID not Name Audit: - GET /networks ListNetworks - GET /networks/{id} InspectNetwork - DELETE /networks/{id} RemoveNetwork - POST /networks/create CreateNetwork - POST /networks/prune 405 not implemented Signed-off-by: Jhon Honce --- pkg/api/handlers/compat/networks.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'pkg/api') diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index b4f3aa2f1..fe13971b0 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -271,11 +271,16 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) { return } + net, err := getNetworkResourceByNameOrID(name, runtime, nil) + if err != nil { + utils.InternalServerError(w, err) + return + } body := struct { Id string Warning []string }{ - Id: name, + Id: net.ID, } utils.WriteResponse(w, http.StatusCreated, body) } @@ -320,7 +325,7 @@ func RemoveNetwork(w http.ResponseWriter, r *http.Request) { return } - utils.WriteResponse(w, http.StatusNoContent, "") + utils.WriteResponse(w, http.StatusNoContent, nil) } // Connect adds a container to a network -- cgit v1.2.3-54-g00ecf