summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-08-09 13:32:07 +0000
committerGitHub <noreply@github.com>2022-08-09 13:32:07 +0000
commita7af6ef632606fbb3e40e6e3e207ed6e372031c3 (patch)
tree7fbba48ad8843f698b5a28a9c571b6f79ac0f070 /pkg
parent7992d86ab3f69f5c3b4872a4fecbc340579ba78d (diff)
parent3738221c5201584f570ac01ebf2db96cd17e97d6 (diff)
downloadpodman-a7af6ef632606fbb3e40e6e3e207ed6e372031c3.tar.gz
podman-a7af6ef632606fbb3e40e6e3e207ed6e372031c3.tar.bz2
podman-a7af6ef632606fbb3e40e6e3e207ed6e372031c3.zip
Merge pull request #15246 from TomSweeneyRedHat/dev/tsweeney/buildah1.27.0
Bump to Buildah v1.27.0
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/images_build.go31
-rw-r--r--pkg/bindings/images/build.go9
2 files changed, 40 insertions, 0 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go
index 15cfc824e..a00f0b089 100644
--- a/pkg/api/handlers/compat/images_build.go
+++ b/pkg/api/handlers/compat/images_build.go
@@ -17,6 +17,7 @@ import (
"github.com/containers/buildah"
buildahDefine "github.com/containers/buildah/define"
"github.com/containers/buildah/pkg/parse"
+ "github.com/containers/image/v5/docker/reference"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v4/libpod"
"github.com/containers/podman/v4/pkg/api/handlers/utils"
@@ -78,6 +79,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
AppArmor string `schema:"apparmor"`
BuildArgs string `schema:"buildargs"`
CacheFrom string `schema:"cachefrom"`
+ CacheTo string `schema:"cacheto"`
+ CacheTTL string `schema:"cachettl"`
CgroupParent string `schema:"cgroupparent"`
Compression uint64 `schema:"compression"`
ConfigureNetwork string `schema:"networkmode"`
@@ -386,6 +389,31 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
}
}
+ var cacheFrom reference.Named
+ if _, found := r.URL.Query()["cachefrom"]; found {
+ cacheFrom, err = parse.RepoNameToNamedReference(query.CacheFrom)
+ if err != nil {
+ utils.BadRequest(w, "cacheFrom", query.CacheFrom, err)
+ return
+ }
+ }
+ var cacheTo reference.Named
+ if _, found := r.URL.Query()["cacheto"]; found {
+ cacheTo, err = parse.RepoNameToNamedReference(query.CacheTo)
+ if err != nil {
+ utils.BadRequest(w, "cacheto", query.CacheTo, err)
+ return
+ }
+ }
+ var cacheTTL time.Duration
+ if _, found := r.URL.Query()["cachettl"]; found {
+ cacheTTL, err = time.ParseDuration(query.CacheTTL)
+ if err != nil {
+ utils.BadRequest(w, "cachettl", query.CacheTTL, err)
+ return
+ }
+ }
+
var buildArgs = map[string]string{}
if _, found := r.URL.Query()["buildargs"]; found {
if err := json.Unmarshal([]byte(query.BuildArgs), &buildArgs); err != nil {
@@ -578,6 +606,9 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
AdditionalTags: additionalTags,
Annotations: annotations,
CPPFlags: cppflags,
+ CacheFrom: cacheFrom,
+ CacheTo: cacheTo,
+ CacheTTL: cacheTTL,
Args: buildArgs,
AllPlatforms: query.AllPlatforms,
CommonBuildOpts: &buildah.CommonBuildOptions{
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go
index 6883585e2..2615bc516 100644
--- a/pkg/bindings/images/build.go
+++ b/pkg/bindings/images/build.go
@@ -224,6 +224,15 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
if len(options.Manifest) > 0 {
params.Set("manifest", options.Manifest)
}
+ if options.CacheFrom != nil {
+ params.Set("cachefrom", options.CacheFrom.String())
+ }
+ if options.CacheTo != nil {
+ params.Set("cacheto", options.CacheTo.String())
+ }
+ if int64(options.CacheTTL) != 0 {
+ params.Set("cachettl", options.CacheTTL.String())
+ }
if memSwap := options.CommonBuildOpts.MemorySwap; memSwap > 0 {
params.Set("memswap", strconv.Itoa(int(memSwap)))
}