Skip to content

Commit

Permalink
Merge pull request #10597 from Luap99/prune
Browse files Browse the repository at this point in the history
Fix network prune api docs
  • Loading branch information
openshift-merge-robot authored Jun 8, 2021
2 parents 5d96b8e + 8378a9c commit 3d961ac
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/api/handlers/compat/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func Prune(w http.ResponseWriter, r *http.Request) {
type response struct {
NetworksDeleted []string
}
var prunedNetworks []string //nolint
prunedNetworks := []string{}
for _, pr := range pruneReports {
if pr.Error != nil {
logrus.Error(pr.Error)
Expand Down
7 changes: 0 additions & 7 deletions pkg/api/handlers/compat/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,3 @@ type swagCompatNetworkDisconnectRequest struct {
// in:body
Body struct{ types.NetworkDisconnect }
}

// Network prune
// swagger:response NetworkPruneResponse
type swagCompatNetworkPruneResponse struct {
// in:body
Body []string
}
3 changes: 3 additions & 0 deletions pkg/api/handlers/libpod/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,8 @@ func Prune(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
return
}
if pruneReports == nil {
pruneReports = []*entities.NetworkPruneReport{}
}
utils.WriteResponse(w, http.StatusOK, pruneReports)
}
7 changes: 7 additions & 0 deletions pkg/api/handlers/libpod/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ type swagNetworkCreateReport struct {
Body entities.NetworkCreateReport
}

// Network prune
// swagger:response NetworkPruneResponse
type swagNetworkPruneResponse struct {
// in:body
Body []entities.NetworkPruneReport
}

func ServeSwagger(w http.ResponseWriter, r *http.Request) {
path := DefaultPodmanSwaggerSpec
if p, found := os.LookupEnv("PODMAN_SWAGGER_SPEC"); found {
Expand Down
9 changes: 6 additions & 3 deletions pkg/api/server/register_networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,12 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error {
// 200:
// description: OK
// schema:
// type: array
// items:
// type: string
// type: object
// properties:
// NetworksDeleted:
// type: array
// items:
// type: string
// 500:
// $ref: "#/responses/InternalError"
r.HandleFunc(VersionedPath("/networks/prune"), s.APIHandler(compat.Prune)).Methods(http.MethodPost)
Expand Down

0 comments on commit 3d961ac

Please sign in to comment.