Skip to content

Commit

Permalink
Merge branch 'main' into renovate/git.luolix.top-defenseunicorns-pkg-oci-1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Rodriguez committed Jun 6, 2024
2 parents 6e41e24 + 2707a61 commit 617859b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/internal/packager/images/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,31 @@ func Pull(ctx context.Context, cfg PullConfig) (map[transform.Image]v1.Image, er
doneSaving <- nil
<-doneSaving

// Needed because when pulling from the local docker daemon, while using the docker containerd runtime
// Crane incorrectly names the blob of the docker image config to a sha that does not match the contents
// https://github.com/defenseunicorns/zarf/issues/2584
// This is a band aid fix while we wait for crane and or docker to create the permanent fix
blobDir := filepath.Join(cfg.DestinationDirectory, "blobs", "sha256")
err = filepath.Walk(blobDir, func(path string, fi os.FileInfo, err error) error {
if err != nil {
return err
}

if fi.IsDir() {
return nil
}

hash, err := helpers.GetSHA256OfFile(path)
if err != nil {
return err
}
newFile := filepath.Join(blobDir, hash)
return os.Rename(path, newFile)
})
if err != nil {
return nil, err
}

return fetched, nil
}

Expand Down
6 changes: 4 additions & 2 deletions src/pkg/layout/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ func (i *Images) AddV1Image(img v1.Image) error {
}
i.AddBlob(digest.Hex)
}
imgCfgSha, err := img.ConfigName()
manifest, err := img.Manifest()
if err != nil {
return err
}
i.AddBlob(imgCfgSha.Hex)
// Cannot use img.ConfigName to get this value because of an upstream bug in crane / docker using the containerd runtime
// https://github.com/defenseunicorns/zarf/issues/2584
i.AddBlob(manifest.Config.Digest.Hex)
manifestSha, err := img.Digest()
if err != nil {
return err
Expand Down

0 comments on commit 617859b

Please sign in to comment.