mirror of
https://github.com/moby/buildkit.git
synced 2026-08-09 17:18:11 +00:00
fix bug #3052 Original `convertSchema1ConfigMeta` fuction using the wrong `ocispec.Image` type to unmarshal schemaV1 image config, Which miss ONBUILD field, the correct `Image` type was defined in `frontend/dockerfile/dockerfile2llb/image.go`, I move its definition to `exporter/containerimage/image`, then both package `util/imageutil` and `frontend/dockerfile` could use the correct `Image` type. Signed-off-by: frank yang <yyb196@gmail.com>
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package imageutil
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestConvertSchema1ConfigMeta(t *testing.T) {
|
|
dt := []byte(`{
|
|
"schemaVersion": 1,
|
|
"name": "base-global/common",
|
|
"tag": "1.0.9.zb.standard",
|
|
"architecture": "amd64",
|
|
"fsLayers": [
|
|
{
|
|
"blobSum": "sha256:id1"
|
|
}
|
|
],
|
|
"history": [
|
|
{
|
|
"v1Compatibility": "{\"id\":\"id2\",\"parent\":\"id3\",\"created\":\"2018-07-26T11:56:23.157525618Z\",\"config\":{\"Hostname\":\"4f3d4451\",\"Env\":[\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"],\"Cmd\":null,\"Volumes\":{},\"OnBuild\":[\"ARG APP_NAME\",\"COPY ${APP_NAME}.tgz /home/admin/${APP_NAME}/target/${APP_NAME}.tgz\"],\"Labels\":{}},\"architecture\":\"amd64\",\"os\":\"linux\"}"
|
|
}
|
|
]
|
|
}`)
|
|
result, err := convertSchema1ConfigMeta(dt)
|
|
if err != nil {
|
|
t.Errorf("convertSchema1ConfigMeta error %v", err)
|
|
return
|
|
}
|
|
if !bytes.Contains(result, []byte("OnBuild")) {
|
|
t.Errorf("convertSchema1ConfigMeta lost onbuild")
|
|
} else if !bytes.Contains(result, []byte("COPY ${APP_NAME}.tgz /home/admin/${APP_NAME}/target/${APP_NAME}.tg")) {
|
|
t.Errorf("convertSchema1ConfigMeta lost onbuild content")
|
|
}
|
|
}
|