mirror of
https://github.com/containers/podman.git
synced 2025-12-16 03:57:36 +08:00
Add GET /quadlets/{name}/file
Fixes: https://issues.redhat.com/browse/RUN-3716 Signed-off-by: Nicola Sella <nsella@redhat.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/containers/podman/v6/pkg/domain/entities"
|
||||
"github.com/containers/podman/v6/pkg/domain/infra/abi"
|
||||
"github.com/containers/podman/v6/pkg/util"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func ListQuadlets(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -35,3 +36,23 @@ func ListQuadlets(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
utils.WriteResponse(w, http.StatusOK, quadlets)
|
||||
}
|
||||
|
||||
func GetQuadletPrint(w http.ResponseWriter, r *http.Request) {
|
||||
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
||||
name := utils.GetName(r)
|
||||
|
||||
containerEngine := abi.ContainerEngine{Libpod: runtime}
|
||||
|
||||
quadletContents, err := containerEngine.QuadletPrint(r.Context(), name)
|
||||
if err != nil {
|
||||
utils.Error(w, http.StatusNotFound, fmt.Errorf("no such quadlet: %s: %w", name, err))
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if _, err := w.Write([]byte(quadletContents)); err != nil {
|
||||
logrus.Errorf("Failed to write quadlet contents: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user