Skip to content

Commit

Permalink
Produce actual image digest, not manifest config digest
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Yarotsky <[email protected]>
  • Loading branch information
Vladimir Yarotsky committed Jun 24, 2022
1 parent 3d604da commit db22b1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ func Build(buildkitd *Buildkitd, outputsDir string, req Request) (Response, erro
func writeDigest(dest string, image v1.Image) error {
digestPath := filepath.Join(dest, "digest")

manifest, err := image.Manifest()
digest, err := image.Digest()
if err != nil {
return errors.Wrap(err, "get image digest")
}

err = ioutil.WriteFile(digestPath, []byte(manifest.Config.Digest.String()), 0644)
err = ioutil.WriteFile(digestPath, []byte(digest.String()), 0644)
if err != nil {
return errors.Wrap(err, "write digest file")
}
Expand Down
12 changes: 6 additions & 6 deletions task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ func (s *TaskSuite) TestDigestFile() {
image, err := tarball.ImageFromPath(s.imagePath("image.tar"), nil)
s.NoError(err)

manifest, err := image.Manifest()
actualDigest, err := image.Digest()
s.NoError(err)

s.Equal(string(digest), manifest.Config.Digest.String())
s.Equal(string(digest), actualDigest.String())
}

func (s *TaskSuite) TestDockerfilePath() {
Expand Down Expand Up @@ -522,17 +522,17 @@ func (s *TaskSuite) TestMultiTargetDigest() {
s.NoError(err)
digest, err := ioutil.ReadFile(s.outputPath("additional-target", "digest"))
s.NoError(err)
additionalManifest, err := additionalImage.Manifest()
additionalDigest, err := additionalImage.Digest()
s.NoError(err)
s.Equal(string(digest), additionalManifest.Config.Digest.String())
s.Equal(string(digest), additionalDigest.String())

finalImage, err := tarball.ImageFromPath(s.imagePath("image.tar"), nil)
s.NoError(err)
digest, err = ioutil.ReadFile(s.outputPath("image", "digest"))
s.NoError(err)
finalManifest, err := finalImage.Manifest()
finalDigest, err := finalImage.Digest()
s.NoError(err)
s.Equal(string(digest), finalManifest.Config.Digest.String())
s.Equal(string(digest), finalDigest.String())
}

func (s *TaskSuite) TestMultiTargetUnpack() {
Expand Down

0 comments on commit db22b1c

Please sign in to comment.