Skip to content

✨ Normalize media type for layers during image rebasing #2102

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mrozanc
Copy link

@mrozanc mrozanc commented May 20, 2025

Fix for #2101

Ensure consistent media types (DockerLayer/OCILayer) across layers by adding logic to identify and normalize layer media types during the rebasing process. This prevents potential mismatches and ensures compatibility when constructing rebased images.

mrozanc added 2 commits May 20, 2025 21:07
This test verifies that when rebasing an image, the layer types adapt to match the new base image's type. It ensures consistency in media types by checking that layers from the original image are updated to the new base's type when required.
Ensure consistent media types (DockerLayer/OCILayer) across layers by adding logic to identify and normalize layer media types during the rebasing process. This prevents potential mismatches and ensures compatibility when constructing rebased images.
Copy link

google-cla bot commented May 20, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@mrozanc
Copy link
Author

mrozanc commented May 20, 2025

No idea what's going on with presubmit, but it looks like #908 problem. I'm using WSL to launch presubmit.

./hack/presubmit.sh logs
go: downloading honnef.co/go/tools v0.6.1
go: downloading golang.org/x/tools v0.30.0
go: downloading golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678
go: downloading github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
go: downloading golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
go: downloading golang.org/x/sync v0.11.0
go: downloading golang.org/x/mod v0.23.0
/mnt/c/Users/marc/dev/golang/go-containerregistry
/mnt/c/Users/marc/dev/golang/go-containerregistry /mnt/c/Users/marc/dev/golang/go-containerregistry
ok      github.com/google/go-containerregistry/cmd/crane        3.230s
?       github.com/google/go-containerregistry/cmd/crane/cmd    [no test files]
?       github.com/google/go-containerregistry/cmd/crane/help   [no test files]
ok      github.com/google/go-containerregistry/cmd/gcrane       4.539s
?       github.com/google/go-containerregistry/cmd/gcrane/cmd   [no test files]
?       github.com/google/go-containerregistry/cmd/registry     [no test files]
ok      github.com/google/go-containerregistry/internal/and     (cached)
ok      github.com/google/go-containerregistry/internal/cmd     7.050s
ok      github.com/google/go-containerregistry/internal/compression     (cached)
?       github.com/google/go-containerregistry/internal/depcheck        [no test files]
?       github.com/google/go-containerregistry/internal/editor  [no test files]
ok      github.com/google/go-containerregistry/internal/estargz (cached)
ok      github.com/google/go-containerregistry/internal/gzip    (cached)
?       github.com/google/go-containerregistry/internal/httptest        [no test files]
?       github.com/google/go-containerregistry/internal/redact  [no test files]
ok      github.com/google/go-containerregistry/internal/retry   (cached)
?       github.com/google/go-containerregistry/internal/retry/wait      [no test files]
ok      github.com/google/go-containerregistry/internal/verify  (cached)
ok      github.com/google/go-containerregistry/internal/windows (cached)
ok      github.com/google/go-containerregistry/internal/zstd    (cached)
ok      github.com/google/go-containerregistry/pkg/authn        0.219s
ok      github.com/google/go-containerregistry/pkg/authn/github (cached)
?       github.com/google/go-containerregistry/pkg/compression  [no test files]
ok      github.com/google/go-containerregistry/pkg/crane        23.504s
ok      github.com/google/go-containerregistry/pkg/gcrane       9.197s
?       github.com/google/go-containerregistry/pkg/legacy       [no test files]
ok      github.com/google/go-containerregistry/pkg/legacy/tarball       (cached)
?       github.com/google/go-containerregistry/pkg/logs [no test files]
ok      github.com/google/go-containerregistry/pkg/name (cached)
ok      github.com/google/go-containerregistry/pkg/registry     2.140s
ok      github.com/google/go-containerregistry/pkg/v1   (cached)
ok      github.com/google/go-containerregistry/pkg/v1/cache     (cached)
ok      github.com/google/go-containerregistry/pkg/v1/compare   (cached)
ok      github.com/google/go-containerregistry/pkg/v1/daemon    (cached)
ok      github.com/google/go-containerregistry/pkg/v1/empty     (cached)
?       github.com/google/go-containerregistry/pkg/v1/fake      [no test files]
--- FAIL: TestGcloudErrors (0.62s)
    --- FAIL: TestGcloudErrors/error (0.24s)
        auth_test.go:119: wanted error, got nil
    --- FAIL: TestGcloudErrors/badoutput (0.19s)
        auth_test.go:119: wanted error, got nil
    --- FAIL: TestGcloudErrors/badexpiry (0.19s)
        auth_test.go:119: wanted error, got nil
--- FAIL: TestGcloudSuccess (0.24s)
    auth_test.go:146: wanted token "mytoken", got ""
--- FAIL: TestKeychainGCRandAR (1.82s)
    --- FAIL: TestKeychainGCRandAR/cases[0] (0.22s)
        auth_test.go:212: expected not anonymous auth for {gcr.io true}, got: &{}
        auth_test.go:223: expected not anonymous auth for {gcr.io true}, got: &{}
    --- FAIL: TestKeychainGCRandAR/cases[1] (0.17s)
        auth_test.go:212: expected not anonymous auth for {us.gcr.io true}, got: &{}
        auth_test.go:223: expected not anonymous auth for {us.gcr.io true}, got: &{}
    --- FAIL: TestKeychainGCRandAR/cases[2] (0.18s)
        auth_test.go:212: expected not anonymous auth for {eu.gcr.io true}, got: &{}
        auth_test.go:223: expected not anonymous auth for {eu.gcr.io true}, got: &{}
    --- FAIL: TestKeychainGCRandAR/cases[3] (0.18s)
        auth_test.go:212: expected not anonymous auth for {asia.gcr.io true}, got: &{}
        auth_test.go:223: expected not anonymous auth for {asia.gcr.io true}, got: &{}
    --- FAIL: TestKeychainGCRandAR/cases[4] (0.21s)
        auth_test.go:212: expected not anonymous auth for {staging-k8s.gcr.io true}, got: &{}
        auth_test.go:223: expected not anonymous auth for {staging-k8s.gcr.io true}, got: &{}
    --- FAIL: TestKeychainGCRandAR/cases[5] (0.13s)
        auth_test.go:212: expected not anonymous auth for {global.gcr.io true}, got: &{}
        auth_test.go:223: expected not anonymous auth for {global.gcr.io true}, got: &{}
    --- FAIL: TestKeychainGCRandAR/cases[9] (0.13s)
        auth_test.go:212: expected not anonymous auth for {us-docker.pkg.dev true}, got: &{}
        auth_test.go:223: expected not anonymous auth for {us-docker.pkg.dev true}, got: &{}
    --- FAIL: TestKeychainGCRandAR/cases[10] (0.14s)
        auth_test.go:212: expected not anonymous auth for {asia-docker.pkg.dev true}, got: &{}
        auth_test.go:223: expected not anonymous auth for {asia-docker.pkg.dev true}, got: &{}
    --- FAIL: TestKeychainGCRandAR/cases[11] (0.20s)
        auth_test.go:212: expected not anonymous auth for {europe-docker.pkg.dev true}, got: &{}
        auth_test.go:223: expected not anonymous auth for {europe-docker.pkg.dev true}, got: &{}
    --- FAIL: TestKeychainGCRandAR/cases[12] (0.26s)
        auth_test.go:212: expected not anonymous auth for {us-central1-docker.pkg.dev true}, got: &{}
        auth_test.go:223: expected not anonymous auth for {us-central1-docker.pkg.dev true}, got: &{}
FAIL
FAIL    github.com/google/go-containerregistry/pkg/v1/google    5.348s
ok      github.com/google/go-containerregistry/pkg/v1/layout    (cached)
ok      github.com/google/go-containerregistry/pkg/v1/match     (cached)
ok      github.com/google/go-containerregistry/pkg/v1/mutate    (cached)
ok      github.com/google/go-containerregistry/pkg/v1/partial   (cached)
ok      github.com/google/go-containerregistry/pkg/v1/random    (cached)
ok      github.com/google/go-containerregistry/pkg/v1/remote    5.496s
ok      github.com/google/go-containerregistry/pkg/v1/remote/transport  (cached)
ok      github.com/google/go-containerregistry/pkg/v1/static    (cached)
ok      github.com/google/go-containerregistry/pkg/v1/stream    (cached)
ok      github.com/google/go-containerregistry/pkg/v1/tarball   (cached)
ok      github.com/google/go-containerregistry/pkg/v1/types     (cached)
?       github.com/google/go-containerregistry/pkg/v1/validate  [no test files]
FAIL

Edit: actually it fails because when gcloud is not installed, the production code still looks for it and fallbacks to anonymous mode instead of using the mock provided in the test.

@mrozanc mrozanc marked this pull request as draft May 20, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant