pkg/api: api list quadlets resource

Signed-off-by: Celso Henrique Souza Silva <celsohenrique367@gmail.com>
This commit is contained in:
Celso Henrique Souza Silva
2025-09-30 18:44:04 -03:00
parent d58e496a5e
commit a724fce8aa
5 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
//go:build !remote
package libpod
import (
"fmt"
"net/http"
"github.com/containers/podman/v5/libpod"
"github.com/containers/podman/v5/pkg/api/handlers/utils"
api "github.com/containers/podman/v5/pkg/api/types"
"github.com/containers/podman/v5/pkg/domain/entities"
"github.com/containers/podman/v5/pkg/domain/infra/abi"
"github.com/containers/podman/v5/pkg/util"
)
func ListQuadlets(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
filterMap, err := util.FiltersFromRequest(r)
if err != nil {
utils.Error(
w, http.StatusInternalServerError,
fmt.Errorf("failed to parse parameters for %s: %w", r.URL.String(), err),
)
return
}
containerEngine := abi.ContainerEngine{Libpod: runtime}
quadlets, err := containerEngine.QuadletList(r.Context(), entities.QuadletListOptions{Filters: filterMap})
if err != nil {
utils.InternalServerError(w, err)
return
}
utils.WriteResponse(w, http.StatusOK, quadlets)
}