summaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/handlers/compat/images_build.go22
-rw-r--r--pkg/api/handlers/compat/images_remove.go35
-rw-r--r--pkg/api/server/swagger.go2
3 files changed, 34 insertions, 25 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go
index 0a63d6e1c..36785a362 100644
--- a/pkg/api/handlers/compat/images_build.go
+++ b/pkg/api/handlers/compat/images_build.go
@@ -13,6 +13,7 @@ import (
"time"
"github.com/containers/buildah"
+ "github.com/containers/buildah/define"
"github.com/containers/buildah/imagebuildah"
"github.com/containers/buildah/util"
"github.com/containers/image/v5/types"
@@ -98,6 +99,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
OutputFormat string `schema:"outputformat"`
Platform string `schema:"platform"`
Pull bool `schema:"pull"`
+ PullPolicy string `schema:"pullpolicy"`
Quiet bool `schema:"q"`
Registry string `schema:"registry"`
Rm bool `schema:"rm"`
@@ -199,13 +201,9 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
}
format := buildah.Dockerv2ImageManifest
registry := query.Registry
- isolation := buildah.IsolationChroot
- /*
- // FIXME, This is very broken. Buildah will only work with chroot
- isolation := buildah.IsolationDefault
- */
+ isolation := buildah.IsolationDefault
if utils.IsLibpodRequest(r) {
- // isolation = parseLibPodIsolation(query.Isolation)
+ isolation = parseLibPodIsolation(query.Isolation)
registry = ""
format = query.OutputFormat
} else {
@@ -279,10 +277,14 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
jobs = query.Jobs
}
- pullPolicy := buildah.PullIfMissing
- if _, found := r.URL.Query()["pull"]; found {
- if query.Pull {
- pullPolicy = buildah.PullAlways
+ pullPolicy := define.PullIfMissing
+ if utils.IsLibpodRequest(r) {
+ pullPolicy = define.PolicyMap[query.PullPolicy]
+ } else {
+ if _, found := r.URL.Query()["pull"]; found {
+ if query.Pull {
+ pullPolicy = define.PullAlways
+ }
}
}
diff --git a/pkg/api/handlers/compat/images_remove.go b/pkg/api/handlers/compat/images_remove.go
index 874c57f16..e89558a86 100644
--- a/pkg/api/handlers/compat/images_remove.go
+++ b/pkg/api/handlers/compat/images_remove.go
@@ -4,7 +4,10 @@ import (
"net/http"
"github.com/containers/podman/v3/libpod"
+ "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
+ "github.com/containers/podman/v3/pkg/domain/entities"
+ "github.com/containers/podman/v3/pkg/domain/infra/abi"
"github.com/gorilla/schema"
"github.com/pkg/errors"
)
@@ -30,28 +33,32 @@ func RemoveImage(w http.ResponseWriter, r *http.Request) {
}
}
name := utils.GetName(r)
- newImage, err := runtime.ImageRuntime().NewFromLocal(name)
- if err != nil {
- utils.ImageNotFound(w, name, errors.Wrapf(err, "failed to find image %s", name))
- return
+ imageEngine := abi.ImageEngine{Libpod: runtime}
+
+ options := entities.ImageRemoveOptions{
+ Force: query.Force,
}
+ report, rmerrors := imageEngine.Remove(r.Context(), []string{name}, options)
+ if len(rmerrors) > 0 && rmerrors[0] != nil {
+ err := rmerrors[0]
+ if errors.Cause(err) == define.ErrNoSuchImage {
+ utils.ImageNotFound(w, name, errors.Wrapf(err, "failed to find image %s", name))
+ return
+ }
- results, err := runtime.RemoveImage(r.Context(), newImage, query.Force)
- if err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
return
}
-
- response := make([]map[string]string, 0, len(results.Untagged)+1)
- deleted := make(map[string]string, 1)
- deleted["Deleted"] = results.Deleted
- response = append(response, deleted)
-
- for _, u := range results.Untagged {
+ response := make([]map[string]string, 0, len(report.Untagged)+1)
+ for _, d := range report.Deleted {
+ deleted := make(map[string]string, 1)
+ deleted["Deleted"] = d
+ response = append(response, deleted)
+ }
+ for _, u := range report.Untagged {
untagged := make(map[string]string, 1)
untagged["Untagged"] = u
response = append(response, untagged)
}
-
utils.WriteResponse(w, http.StatusOK, response)
}
diff --git a/pkg/api/server/swagger.go b/pkg/api/server/swagger.go
index 12fd083bb..d282edf23 100644
--- a/pkg/api/server/swagger.go
+++ b/pkg/api/server/swagger.go
@@ -205,7 +205,7 @@ type swagHealthCheckRunResponse struct {
type swagVersion struct {
// in:body
Body struct {
- entities.SystemVersionReport
+ entities.ComponentVersion
}
}