diff --git a/src/internal/packager/images/pull.go b/src/internal/packager/images/pull.go index 3b0e05dddc..c440f8d33d 100644 --- a/src/internal/packager/images/pull.go +++ b/src/internal/packager/images/pull.go @@ -246,34 +246,6 @@ func Pull(ctx context.Context, cfg PullConfig) (map[transform.Image]v1.Image, er doneSaving <- nil <-doneSaving - // This fixes an issue on amd64, when pulling images 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 the docker to create the permanent fix - blobDirectory := filepath.Join(cfg.DestinationDirectory, "images", "blobs", "sha256") - err = filepath.Walk(blobDirectory, func(path string, _ os.FileInfo, err error) error { - if err != nil { - return err - } - - file, err := os.Open(path) - if err != nil { - return err - } - defer file.Close() - - hash, err := helpers.GetSHA256Hash(file) - if err != nil { - return err - } - - return os.Rename(path, hash) - }) - if err != nil { - return nil, err - } - return fetched, nil } diff --git a/src/pkg/layout/image.go b/src/pkg/layout/image.go index 15348bf1d3..dc19789034 100644 --- a/src/pkg/layout/image.go +++ b/src/pkg/layout/image.go @@ -5,10 +5,12 @@ package layout import ( + "os" "path/filepath" "slices" + "github.com/defenseunicorns/pkg/helpers" v1 "github.com/google/go-containerregistry/pkg/v1" ) @@ -25,9 +27,18 @@ func (i *Images) AddBlob(blob string) { if len(blob) != 64 { return } - abs := filepath.Join(i.Base, "blobs", "sha256", blob) - if !slices.Contains(i.Blobs, abs) { - i.Blobs = append(i.Blobs, abs) + layerPath := filepath.Join(i.Base, "blobs", "sha256") + abs := filepath.Join(layerPath, blob) + absSha, err := helpers.GetSHA256OfFile(abs) + if err != nil { + return + } + newPath := filepath.Join(layerPath, absSha) + if absSha != blob { + os.Rename(abs, newPath) + } + if !slices.Contains(i.Blobs, newPath) { + i.Blobs = append(i.Blobs, newPath) } }