diff --git a/src/internal/packager/images/pull.go b/src/internal/packager/images/pull.go index c440f8d33d..9063075879 100644 --- a/src/internal/packager/images/pull.go +++ b/src/internal/packager/images/pull.go @@ -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 } diff --git a/src/pkg/layout/image.go b/src/pkg/layout/image.go index 15348bf1d3..7d236410bf 100644 --- a/src/pkg/layout/image.go +++ b/src/pkg/layout/image.go @@ -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