Exporter config digest typo

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
v0.9
CrazyMax 2021-07-15 20:42:30 +02:00
parent 66d30551db
commit f4a67d7e9c
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
6 changed files with 29 additions and 20 deletions

View File

@ -31,6 +31,7 @@ import (
"github.com/containerd/containerd/snapshots"
"github.com/containerd/continuity/fs/fstest"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
gateway "github.com/moby/buildkit/frontend/gateway/client"
"github.com/moby/buildkit/identity"
"github.com/moby/buildkit/session"
@ -591,10 +592,10 @@ func testPushByDigest(t *testing.T, sb integration.Sandbox) {
_, _, err = contentutil.ProviderFromRef(name + ":latest")
require.Error(t, err)
desc, _, err := contentutil.ProviderFromRef(name + "@" + resp.ExporterResponse["containerimage.digest"])
desc, _, err := contentutil.ProviderFromRef(name + "@" + resp.ExporterResponse[exptypes.ExporterImageDigestKey])
require.NoError(t, err)
require.Equal(t, resp.ExporterResponse["containerimage.digest"], desc.Digest.String())
require.Equal(t, resp.ExporterResponse[exptypes.ExporterImageDigestKey], desc.Digest.String())
require.Equal(t, images.MediaTypeDockerSchema2Manifest, desc.MediaType)
require.True(t, desc.Size > 0)
}
@ -1861,19 +1862,19 @@ func testExporterTargetExists(t *testing.T, sb integration.Sandbox) {
Type: ExporterOCI,
Attrs: map[string]string{},
Output: func(m map[string]string) (io.WriteCloser, error) {
mdDgst = m["containerimage.digest"]
mdDgst = m[exptypes.ExporterImageDigestKey]
return nil, nil
},
},
},
}, nil)
require.NoError(t, err)
dgst := res.ExporterResponse["containerimage.digest"]
dgst := res.ExporterResponse[exptypes.ExporterImageDigestKey]
require.True(t, strings.HasPrefix(dgst, "sha256:"))
require.Equal(t, dgst, mdDgst)
require.True(t, strings.HasPrefix(res.ExporterResponse["containerimage.config.digest"], "sha256:"))
require.True(t, strings.HasPrefix(res.ExporterResponse[exptypes.ExporterImageConfigDigestKey], "sha256:"))
}
func testTarExporterWithSocket(t *testing.T, sb integration.Sandbox) {
@ -2792,7 +2793,7 @@ func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
}, nil)
require.NoError(t, err)
dgst, ok := resp.ExporterResponse["containerimage.digest"]
dgst, ok := resp.ExporterResponse[exptypes.ExporterImageDigestKey]
require.Equal(t, ok, true)
unique, err := readFileInImage(sb.Context(), c, target+"@"+dgst, "/unique")
@ -2831,7 +2832,7 @@ func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
}, nil)
require.NoError(t, err)
dgst2, ok := resp.ExporterResponse["containerimage.digest"]
dgst2, ok := resp.ExporterResponse[exptypes.ExporterImageDigestKey]
require.Equal(t, ok, true)
require.Equal(t, dgst, dgst2)
@ -2862,7 +2863,7 @@ func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
}, nil)
require.NoError(t, err)
dgst3, ok := resp.ExporterResponse["containerimage.digest"]
dgst3, ok := resp.ExporterResponse[exptypes.ExporterImageDigestKey]
require.Equal(t, ok, true)
// dgst3 != dgst, because inline cache is not exported for dgst3

View File

@ -17,6 +17,7 @@ import (
"github.com/containerd/containerd/namespaces"
"github.com/containerd/continuity/fs/fstest"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/util/testutil/integration"
"github.com/stretchr/testify/require"
)
@ -147,7 +148,7 @@ func testBuildMetadataFile(t *testing.T, sb integration.Sandbox) {
require.Equal(t, imageName, metadata["image.name"])
digest := metadata["containerimage.digest"]
digest := metadata[exptypes.ExporterImageDigestKey]
require.NotEmpty(t, digest)
cdAddress := sb.ContainerdAddress()

View File

@ -16,6 +16,7 @@ import (
"github.com/containerd/containerd/rootfs"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/exporter"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/snapshot"
"github.com/moby/buildkit/util/compression"
@ -284,9 +285,9 @@ func (e *imageExporterInstance) Export(ctx context.Context, src exporter.Source,
resp["image.name"] = e.targetName
}
resp["containerimage.digest"] = desc.Digest.String()
if v, ok := desc.Annotations["config.digest"]; ok {
resp["containerimage.config.digest"] = v
resp[exptypes.ExporterImageDigestKey] = desc.Digest.String()
if v, ok := desc.Annotations[exptypes.ExporterConfigDigestKey]; ok {
resp[exptypes.ExporterImageConfigDigestKey] = v
}
return resp, nil
}

View File

@ -5,9 +5,14 @@ import (
specs "github.com/opencontainers/image-spec/specs-go/v1"
)
const ExporterImageConfigKey = "containerimage.config"
const ExporterInlineCache = "containerimage.inlinecache"
const ExporterPlatformsKey = "refs.platforms"
const (
ExporterConfigDigestKey = "config.digest"
ExporterImageDigestKey = "containerimage.digest"
ExporterImageConfigKey = "containerimage.config"
ExporterImageConfigDigestKey = "containerimage.config.digest"
ExporterInlineCache = "containerimage.inlinecache"
ExporterPlatformsKey = "refs.platforms"
)
const EmptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")

View File

@ -67,7 +67,7 @@ func (ic *ImageWriter) Commit(ctx context.Context, inp exporter.Source, oci bool
if mfstDesc.Annotations == nil {
mfstDesc.Annotations = make(map[string]string)
}
mfstDesc.Annotations["config.digest"] = configDesc.Digest.String()
mfstDesc.Annotations[exptypes.ExporterConfigDigestKey] = configDesc.Digest.String()
return mfstDesc, nil
}

View File

@ -12,6 +12,7 @@ import (
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/exporter"
"github.com/moby/buildkit/exporter/containerimage"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/session/filesync"
"github.com/moby/buildkit/util/compression"
@ -150,10 +151,10 @@ func (e *imageExporterInstance) Export(ctx context.Context, src exporter.Source,
desc.Annotations[ocispec.AnnotationCreated] = time.Now().UTC().Format(time.RFC3339)
resp := make(map[string]string)
resp["containerimage.digest"] = desc.Digest.String()
if v, ok := desc.Annotations["config.digest"]; ok {
resp["containerimage.config.digest"] = v
delete(desc.Annotations, "config.digeest")
resp[exptypes.ExporterImageDigestKey] = desc.Digest.String()
if v, ok := desc.Annotations[exptypes.ExporterConfigDigestKey]; ok {
resp[exptypes.ExporterImageConfigDigestKey] = v
delete(desc.Annotations, exptypes.ExporterConfigDigestKey)
}
if n, ok := src.Metadata["image.name"]; e.name == "*" && ok {