Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mismatched mediaType error when push image build with warmed bas… #3231

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"github.com/google/go-containerregistry/pkg/v1/layout"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/google/go-containerregistry/pkg/v1/tarball"
"github.com/google/go-containerregistry/pkg/v1/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -228,11 +229,6 @@
}

func cachedImageFromPath(p string) (v1.Image, error) {
imgTar, err := tarball.ImageFromPath(p, nil)
if err != nil {
return nil, errors.Wrap(err, "getting image from path")
}

// Manifests may be present next to the tar, named with a ".json" suffix
mfstPath := p + ".json"

Expand All @@ -248,9 +244,28 @@
}
}

var imgTar v1.Image
var err error
switch extractMediaTypeVendor(mfst.MediaType) {
case types.DockerVendorPrefix:
imgTar, err = tarball.ImageFromPath(p, nil)
case types.OCIVendorPrefix:
imgTar, err = tarball.OCIImageFromPath(p, nil)

Check failure on line 253 in pkg/cache/cache.go

View workflow job for this annotation

GitHub Actions / tests (integration-test-layers)

undefined: tarball.OCIImageFromPath

Check failure on line 253 in pkg/cache/cache.go

View workflow job for this annotation

GitHub Actions / tests

undefined: tarball.OCIImageFromPath

Check failure on line 253 in pkg/cache/cache.go

View workflow job for this annotation

GitHub Actions / tests (integration-test-misc)

undefined: tarball.OCIImageFromPath

Check failure on line 253 in pkg/cache/cache.go

View workflow job for this annotation

GitHub Actions / tests (integration-test-misc)

undefined: tarball.OCIImageFromPath

Check failure on line 253 in pkg/cache/cache.go

View workflow job for this annotation

GitHub Actions / tests (integration-test-run)

undefined: tarball.OCIImageFromPath
}
if err != nil {
return nil, errors.Wrap(err, "getting image from path")
}

return &cachedImage{
digest: filepath.Base(p),
Image: imgTar,
mfst: mfst,
}, nil
}

func extractMediaTypeVendor(mt types.MediaType) string {
if strings.Contains(string(mt), types.OCIVendorPrefix) {
return types.OCIVendorPrefix
}
return types.DockerVendorPrefix
}
Loading