Skip to content

Commit

Permalink
Merge pull request #16894 from flouthoc/bump-buildah-ca578b290144
Browse files Browse the repository at this point in the history
vendor: bump to buildah `ca578b290144` and use new distributed cache API
  • Loading branch information
openshift-merge-robot authored Dec 20, 2022
2 parents db648dc + 987c8e3 commit ca40371
Show file tree
Hide file tree
Showing 34 changed files with 225 additions and 210 deletions.
8 changes: 4 additions & 4 deletions cmd/podman/images/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,16 +527,16 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
}
}
}
var cacheTo reference.Named
var cacheFrom reference.Named
var cacheTo []reference.Named
var cacheFrom []reference.Named
if c.Flag("cache-to").Changed {
cacheTo, err = parse.RepoNameToNamedReference(flags.CacheTo)
cacheTo, err = parse.RepoNamesToNamedReferences(flags.CacheTo)
if err != nil {
return nil, fmt.Errorf("unable to parse value provided `%s` to --cache-to: %w", flags.CacheTo, err)
}
}
if c.Flag("cache-from").Changed {
cacheFrom, err = parse.RepoNameToNamedReference(flags.CacheFrom)
cacheFrom, err = parse.RepoNamesToNamedReferences(flags.CacheFrom)
if err != nil {
return nil, fmt.Errorf("unable to parse value provided `%s` to --cache-from: %w", flags.CacheTo, err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/container-orchestrated-devices/container-device-interface v0.5.3
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/plugins v1.1.1
github.com/containers/buildah v1.28.1-0.20221130132810-cf661299d14f
github.com/containers/buildah v1.28.1-0.20221219201600-ca578b290144
github.com/containers/common v0.50.2-0.20221216120044-ef7e0d6f3002
github.com/containers/conmon v2.0.20+incompatible
github.com/containers/image/v5 v5.23.1-0.20221216122512-3963f229df32
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHV
github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRDjeJr6FLK6vuiUwoH7P8=
github.com/containernetworking/plugins v1.1.1 h1:+AGfFigZ5TiQH00vhR8qPeSatj53eNGz0C1d3wVYlHE=
github.com/containernetworking/plugins v1.1.1/go.mod h1:Sr5TH/eBsGLXK/h71HeLfX19sZPp3ry5uHSkI4LPxV8=
github.com/containers/buildah v1.28.1-0.20221130132810-cf661299d14f h1:Nzbda2tG7/aimoKnDxysqFgS1Q/gSsbcn88lFPj9LwY=
github.com/containers/buildah v1.28.1-0.20221130132810-cf661299d14f/go.mod h1:0HcSoS6BHXWzMKqtxY1L0gupebEX33oPC+X62lPi6+c=
github.com/containers/buildah v1.28.1-0.20221219201600-ca578b290144 h1:2RQIBdC4z6JeUysEBFmdyRjeQL+XHikWGxDoWiPDsAw=
github.com/containers/buildah v1.28.1-0.20221219201600-ca578b290144/go.mod h1:UtGNHlAwNF1WV/Z63R/sPgxItTog/YPi/1gSfZ8ZdpE=
github.com/containers/common v0.50.2-0.20221216120044-ef7e0d6f3002 h1:wvT0IrvGcZ0tEAvF1CYjaI6xjQjXr4vDnrlHRAYEo0Q=
github.com/containers/common v0.50.2-0.20221216120044-ef7e0d6f3002/go.mod h1:EhEJRALj8qJWhnnzk6nY6wqDkSjfGpU2DwcLb9UpVoM=
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
Expand Down
57 changes: 20 additions & 37 deletions pkg/api/handlers/compat/images_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,47 +400,30 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
}
}

// Docker's newer clients popuates `cacheFrom` and `cacheTo` parameter
// by default as empty array for all commands but buildah's design of
// distributed cache expects this to be a repo not image hence parse
// only the first populated repo and ignore if empty array.
// Read more here: https://github.com/containers/podman/issues/15928
// TODO: Remove this when buildah's API is extended.
compatIgnoreForcedCacheOptions := func(queryStr string) string {
query := queryStr
if strings.HasPrefix(query, "[") {
query = ""
var arr []string
parseErr := json.Unmarshal([]byte(query), &arr)
if parseErr != nil {
if len(arr) > 0 {
query = arr[0]
}
}
}
return query
}

var cacheFrom reference.Named
cacheFrom := []reference.Named{}
if _, found := r.URL.Query()["cachefrom"]; found {
cacheFromQuery := compatIgnoreForcedCacheOptions(query.CacheFrom)
if cacheFromQuery != "" {
cacheFrom, err = parse.RepoNameToNamedReference(cacheFromQuery)
if err != nil {
utils.BadRequest(w, "cacheFrom", cacheFromQuery, err)
return
}
var cacheFromSrcList []string
if err := json.Unmarshal([]byte(query.CacheFrom), &cacheFromSrcList); err != nil {
utils.BadRequest(w, "cacheFrom", query.CacheFrom, err)
return
}
cacheFrom, err = parse.RepoNamesToNamedReferences(cacheFromSrcList)
if err != nil {
utils.BadRequest(w, "cacheFrom", query.CacheFrom, err)
return
}
}
var cacheTo reference.Named
cacheTo := []reference.Named{}
if _, found := r.URL.Query()["cacheto"]; found {
cacheToQuery := compatIgnoreForcedCacheOptions(query.CacheTo)
if cacheToQuery != "" {
cacheTo, err = parse.RepoNameToNamedReference(cacheToQuery)
if err != nil {
utils.BadRequest(w, "cacheto", cacheToQuery, err)
return
}
var cacheToDestList []string
if err := json.Unmarshal([]byte(query.CacheTo), &cacheToDestList); err != nil {
utils.BadRequest(w, "cacheTo", query.CacheTo, err)
return
}
cacheTo, err = parse.RepoNamesToNamedReferences(cacheToDestList)
if err != nil {
utils.BadRequest(w, "cacheto", query.CacheTo, err)
return
}
}
var cacheTTL time.Duration
Expand Down
20 changes: 18 additions & 2 deletions pkg/bindings/images/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,15 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
params.Set("manifest", options.Manifest)
}
if options.CacheFrom != nil {
params.Set("cachefrom", options.CacheFrom.String())
cacheFrom := []string{}
for _, cacheSrc := range options.CacheFrom {
cacheFrom = append(cacheFrom, cacheSrc.String())
}
cacheFromJSON, err := jsoniter.MarshalToString(cacheFrom)
if err != nil {
return nil, err
}
params.Set("cachefrom", cacheFromJSON)
}

switch options.SkipUnusedStages {
Expand All @@ -242,7 +250,15 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
}

if options.CacheTo != nil {
params.Set("cacheto", options.CacheTo.String())
cacheTo := []string{}
for _, cacheSrc := range options.CacheTo {
cacheTo = append(cacheTo, cacheSrc.String())
}
cacheToJSON, err := jsoniter.MarshalToString(cacheTo)
if err != nil {
return nil, err
}
params.Set("cacheto", cacheToJSON)
}
if int64(options.CacheTTL) != 0 {
params.Set("cachettl", options.CacheTTL.String())
Expand Down
36 changes: 18 additions & 18 deletions vendor/github.com/containers/buildah/.cirrus.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions vendor/github.com/containers/buildah/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions vendor/github.com/containers/buildah/add.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions vendor/github.com/containers/buildah/buildah.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions vendor/github.com/containers/buildah/commit.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/containers/buildah/define/build.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ca40371

Please sign in to comment.