github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/api/handlers/compat/changes.go (about) 1 package compat 2 3 import ( 4 "net/http" 5 6 "github.com/hanks177/podman/v4/libpod" 7 "github.com/hanks177/podman/v4/libpod/define" 8 "github.com/hanks177/podman/v4/pkg/api/handlers/utils" 9 api "github.com/hanks177/podman/v4/pkg/api/types" 10 "github.com/gorilla/schema" 11 "github.com/pkg/errors" 12 ) 13 14 func Changes(w http.ResponseWriter, r *http.Request) { 15 decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder) 16 runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) 17 18 query := struct { 19 Parent string `schema:"parent"` 20 DiffType string `schema:"diffType"` 21 }{} 22 if err := decoder.Decode(&query, r.URL.Query()); err != nil { 23 utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String())) 24 return 25 } 26 var diffType define.DiffType 27 switch query.DiffType { 28 case "", "all": 29 diffType = define.DiffAll 30 case "container": 31 diffType = define.DiffContainer 32 case "image": 33 diffType = define.DiffImage 34 default: 35 utils.Error(w, http.StatusBadRequest, errors.Errorf("invalid diffType value %q", query.DiffType)) 36 return 37 } 38 39 id := utils.GetName(r) 40 changes, err := runtime.GetDiff(query.Parent, id, diffType) 41 if err != nil { 42 utils.InternalServerError(w, err) 43 return 44 } 45 utils.WriteJSON(w, 200, changes) 46 }