Merge pull request #1042 from tonistiigi/update-buildkit-220403-v0.8
[v0.8] vendor: update buildkit to 10e6f94bpull/1077/head v0.8.2
commit
6224def4dd
@ -0,0 +1,32 @@
|
||||
package imageutil
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
|
||||
binfotypes "github.com/moby/buildkit/util/buildinfo/types"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// BuildInfo returns build info from image config.
|
||||
func BuildInfo(dt []byte) (*binfotypes.BuildInfo, error) {
|
||||
if len(dt) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
var config binfotypes.ImageConfig
|
||||
if err := json.Unmarshal(dt, &config); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to unmarshal image config")
|
||||
}
|
||||
if len(config.BuildInfo) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
dtbi, err := base64.StdEncoding.DecodeString(config.BuildInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var bi binfotypes.BuildInfo
|
||||
if err = json.Unmarshal(dtbi, &bi); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to decode buildinfo from image config")
|
||||
}
|
||||
return &bi, nil
|
||||
}
|
Loading…
Reference in New Issue