mirror of
https://github.com/containers/podman.git
synced 2025-06-01 01:00:22 +08:00
V2 podman image prune
* Fixed header for `podman image ls` * Implemented prune `all` flag, preserved filter method for backwards capability * Updated binding tests Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
@ -64,6 +64,7 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
|
||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||
|
||||
query := struct {
|
||||
All bool
|
||||
Filters map[string][]string `schema:"filters"`
|
||||
}{
|
||||
// This is where you can override the golang default value for one of fields
|
||||
@ -80,7 +81,7 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
|
||||
filters = append(filters, fmt.Sprintf("%s=%s", k, val))
|
||||
}
|
||||
}
|
||||
pruneCids, err := runtime.ImageRuntime().PruneImages(r.Context(), false, filters)
|
||||
pruneCids, err := runtime.ImageRuntime().PruneImages(r.Context(), query.All, filters)
|
||||
if err != nil {
|
||||
utils.InternalServerError(w, err)
|
||||
return
|
||||
|
@ -119,12 +119,12 @@ func GetImages(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func PruneImages(w http.ResponseWriter, r *http.Request) {
|
||||
var (
|
||||
all bool
|
||||
err error
|
||||
)
|
||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||
decoder := r.Context().Value("decoder").(*schema.Decoder)
|
||||
query := struct {
|
||||
All bool `schema:"all"`
|
||||
Filters map[string][]string `schema:"filters"`
|
||||
}{
|
||||
// override any golang type defaults
|
||||
@ -140,7 +140,7 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
|
||||
if _, found := r.URL.Query()["filters"]; found {
|
||||
dangling := query.Filters["all"]
|
||||
if len(dangling) > 0 {
|
||||
all, err = strconv.ParseBool(query.Filters["all"][0])
|
||||
query.All, err = strconv.ParseBool(query.Filters["all"][0])
|
||||
if err != nil {
|
||||
utils.InternalServerError(w, err)
|
||||
return
|
||||
@ -152,7 +152,8 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
|
||||
libpodFilters = append(libpodFilters, fmt.Sprintf("%s=%s", k, v[0]))
|
||||
}
|
||||
}
|
||||
cids, err := runtime.ImageRuntime().PruneImages(r.Context(), all, libpodFilters)
|
||||
|
||||
cids, err := runtime.ImageRuntime().PruneImages(r.Context(), query.All, libpodFilters)
|
||||
if err != nil {
|
||||
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
|
||||
return
|
||||
|
Reference in New Issue
Block a user