Merge pull request #9312 from baude/issue9310

Correct compat network prune response
This commit is contained in:
OpenShift Merge Robot 2021-02-11 05:38:35 -05:00 committed by GitHub
commit afe4ce6b1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -400,6 +400,9 @@ func Prune(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
return
}
type response struct {
NetworksDeleted []string
}
var prunedNetworks []string //nolint
for _, pr := range pruneReports {
if pr.Error != nil {
@ -408,5 +411,5 @@ func Prune(w http.ResponseWriter, r *http.Request) {
}
prunedNetworks = append(prunedNetworks, pr.Name)
}
utils.WriteResponse(w, http.StatusOK, prunedNetworks)
utils.WriteResponse(w, http.StatusOK, response{NetworksDeleted: prunedNetworks})
}

View file

@ -483,8 +483,16 @@ class TestApi(unittest.TestCase):
inspect = requests.get(PODMAN_URL + f"/v1.40/networks/{ident}")
self.assertEqual(inspect.status_code, 404, inspect.content)
# network prune
prune_name = "Network_" + "".join(random.choice(string.ascii_letters) for i in range(10))
prune_create = requests.post(PODMAN_URL + "/v1.40/networks/create", json={"Name": prune_name})
self.assertEqual(create.status_code, 201, prune_create.content)
prune = requests.post(PODMAN_URL + "/v1.40/networks/prune")
self.assertEqual(prune.status_code, 200, prune.content)
obj = json.loads(prune.content)
self.assertTrue(prune_name in obj["NetworksDeleted"])
def test_volumes_compat(self):
name = "Volume_" + "".join(random.choice(string.ascii_letters) for i in range(10))