Skip to content

Commit

Permalink
Patch build info
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Aug 15, 2021
1 parent d66e620 commit a962b0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 7 additions & 8 deletions exporter/containerimage/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,13 @@ func patchImageConfig(dt []byte, descs []ocispecs.Descriptor, history []ocispecs
m["moby.buildkit.cache.v0"] = dt
}

// TODO: patch build info
//if buildInfo != nil {
// dt, err := json.Marshal(buildInfo)
// if err != nil {
// return nil, err
// }
// m["moby.buildkit.buildinfo.v0"] = dt
//}
if buildInfo != nil {
dt, err := json.Marshal(buildInfo)
if err != nil {
return nil, err
}
m["moby.buildkit.buildinfo.v0"] = dt
}

dt, err = json.Marshal(m)
return dt, errors.Wrap(err, "failed to marshal config after patch")
Expand Down
4 changes: 4 additions & 0 deletions solver/llbsolver/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -363,6 +364,9 @@ func patchBuildInfo(ctx context.Context, res solver.ResultProxy, dtic []byte) ([
for _, bi := range mbis {
bis = append(bis, bi)
}
sort.Slice(bis, func(i, j int) bool {
return bis[i].Ref < bis[j].Ref
})

return json.Marshal(map[string][]exptypes.BuildInfo{
"sources": bis,
Expand Down

0 comments on commit a962b0e

Please sign in to comment.