diff --git a/libimage/image_test.go b/libimage/image_test.go index a46c94660..d2c0c4d96 100644 --- a/libimage/image_test.go +++ b/libimage/image_test.go @@ -14,8 +14,8 @@ import ( func TestImageFunctions(t *testing.T) { // Note: this will resolve pull from the GCR registry (see // testdata/registries.conf). - busyboxLatest := "docker.io/library/busybox:latest" - busyboxDigest := "docker.io/library/busybox@" + busyboxLatest := "quay.io/libpod/busybox:latest" + busyboxDigest := "quay.io/libpod/busybox@" runtime, cleanup := testNewRuntime(t) defer cleanup() @@ -142,7 +142,7 @@ func TestImageFunctions(t *testing.T) { require.False(t, hasDifferentDigest, "image with same digest should have the same manifest (and hence digest)") // Different images -> different digests - remoteRef, err = alltransports.ParseImageName("docker://docker.io/library/alpine:latest") + remoteRef, err = alltransports.ParseImageName("docker://quay.io/libpod/alpine:latest") require.NoError(t, err) hasDifferentDigest, err = image.HasDifferentDigest(ctx, remoteRef, nil) require.NoError(t, err) @@ -191,7 +191,7 @@ func TestInspectHealthcheck(t *testing.T) { func TestTag(t *testing.T) { // Note: this will resolve pull from the GCR registry (see // testdata/registries.conf). - busyboxLatest := "docker.io/library/busybox:latest" + busyboxLatest := "quay.io/libpod/busybox:latest" runtime, cleanup := testNewRuntime(t) defer cleanup() @@ -214,7 +214,7 @@ func TestTag(t *testing.T) { expectError bool }{ {"foo", "localhost/foo:latest", false}, - {"docker.io/foo", "docker.io/library/foo:latest", false}, + {"docker.io/foo", "quay.io/libpod/foo:latest", false}, {"quay.io/bar/foo:tag", "quay.io/bar/foo:tag", false}, {"registry.com/$invalid", "", true}, {digest, "", true}, @@ -242,7 +242,7 @@ func TestTag(t *testing.T) { func TestUntag(t *testing.T) { // Note: this will resolve pull from the GCR registry (see // testdata/registries.conf). - busyboxLatest := "docker.io/library/busybox:latest" + busyboxLatest := "quay.io/libpod/busybox:latest" runtime, cleanup := testNewRuntime(t) defer cleanup() diff --git a/libimage/push_test.go b/libimage/push_test.go index 444f54d00..36a81ee33 100644 --- a/libimage/push_test.go +++ b/libimage/push_test.go @@ -18,7 +18,7 @@ func TestPush(t *testing.T) { // Prefetch alpine. pullOptions := &PullOptions{} pullOptions.Writer = os.Stdout - _, err := runtime.Pull(ctx, "docker.io/library/alpine:latest", config.PullPolicyAlways, pullOptions) + _, err := runtime.Pull(ctx, "quay.io/libpod/alpine:latest", config.PullPolicyAlways, pullOptions) require.NoError(t, err) pushOptions := &PushOptions{} @@ -76,7 +76,7 @@ func TestPushOtherPlatform(t *testing.T) { pullOptions := &PullOptions{} pullOptions.Writer = os.Stdout pullOptions.Architecture = "arm64" - pulledImages, err := runtime.Pull(ctx, "docker.io/library/alpine:latest", config.PullPolicyAlways, pullOptions) + pulledImages, err := runtime.Pull(ctx, "quay.io/libpod/alpine:latest", config.PullPolicyAlways, pullOptions) require.NoError(t, err) require.Len(t, pulledImages, 1) @@ -90,6 +90,6 @@ func TestPushOtherPlatform(t *testing.T) { require.NoError(t, err) tmp.Close() defer os.Remove(tmp.Name()) - _, err = runtime.Push(ctx, "docker.io/library/alpine:latest", "docker-archive:"+tmp.Name(), pushOptions) + _, err = runtime.Push(ctx, "quay.io/libpod/alpine:latest", "docker-archive:"+tmp.Name(), pushOptions) require.NoError(t, err) } diff --git a/libimage/remove_test.go b/libimage/remove_test.go index 3500dd2ea..3f985d22c 100644 --- a/libimage/remove_test.go +++ b/libimage/remove_test.go @@ -12,7 +12,7 @@ import ( func TestRemoveImages(t *testing.T) { // Note: this will resolve pull from the GCR registry (see // testdata/registries.conf). - busyboxLatest := "docker.io/library/busybox:latest" + busyboxLatest := "quay.io/libpod/busybox:latest" runtime, cleanup := testNewRuntime(t) defer cleanup() diff --git a/libimage/save.go b/libimage/save.go index e1b8c3f75..6eefada0c 100644 --- a/libimage/save.go +++ b/libimage/save.go @@ -27,9 +27,9 @@ type SaveOptions struct { } // Save saves one or more images indicated by `names` in the specified `format` -// to `path`. Supported formats are oci-archive, docker-archive, oci-dir and -// docker-dir. The latter two adhere to the dir transport in the corresponding -// oci or docker v2s2 format. Please note that only docker-archive supports +// to `path`. Supported formats are oci-archive, compat-archive, oci-dir and +// dir. The latter two adhere to the dir transport in the corresponding +// oci or docker v2s2 format. Please note that only compat-archive supports // saving more than one images. Other formats will yield an error attempting // to save more than one. func (r *Runtime) Save(ctx context.Context, names []string, format, path string, options *SaveOptions) error { @@ -46,8 +46,8 @@ func (r *Runtime) Save(ctx context.Context, names []string, format, path string, case 1: // All formats support saving 1. default: - if format != "docker-archive" { - return errors.Errorf("unsupported format %q for saving multiple images (only docker-archive)", format) + if format != "docker-archive" && format != "compat-archive" { + return errors.Errorf("unsupported format %q for saving multiple images (only compat-archive)", format) } if len(options.AdditionalTags) > 0 { return errors.Errorf("cannot save multiple images with multiple tags") @@ -56,13 +56,13 @@ func (r *Runtime) Save(ctx context.Context, names []string, format, path string, // Dispatch the save operations. switch format { - case "oci-archive", "oci-dir", "docker-dir": + case "oci-archive", "oci-dir", "docker-dir", "dir": if len(names) > 1 { return errors.Errorf("%q does not support saving multiple images (%v)", format, names) } return r.saveSingleImage(ctx, names[0], format, path, options) - case "docker-archive": + case "docker-archive", "compat-archive": options.ManifestMIMEType = manifest.DockerV2Schema2MediaType return r.saveDockerArchive(ctx, names, path, options) } @@ -72,7 +72,7 @@ func (r *Runtime) Save(ctx context.Context, names []string, format, path string, } // saveSingleImage saves the specified image name to the specified path. -// Supported formats are "oci-archive", "oci-dir" and "docker-dir". +// Supported formats are "oci-archive", "oci-dir" and "docker-dir", "dir". func (r *Runtime) saveSingleImage(ctx context.Context, name, format, path string, options *SaveOptions) error { image, imageName, err := r.LookupImage(name, nil) if err != nil { @@ -105,7 +105,7 @@ func (r *Runtime) saveSingleImage(ctx context.Context, name, format, path string destRef, err = ociTransport.NewReference(path, tag) options.ManifestMIMEType = ociv1.MediaTypeImageManifest - case "docker-dir": + case "docker-dir", "dir": destRef, err = dirTransport.NewReference(path) options.ManifestMIMEType = manifest.DockerV2Schema2MediaType diff --git a/libimage/save_test.go b/libimage/save_test.go index 8d9d76015..cb13ef69c 100644 --- a/libimage/save_test.go +++ b/libimage/save_test.go @@ -19,9 +19,9 @@ func TestSave(t *testing.T) { // Prefetch alpine, busybox. pullOptions := &PullOptions{} pullOptions.Writer = os.Stdout - _, err := runtime.Pull(ctx, "docker.io/library/alpine:latest", config.PullPolicyAlways, pullOptions) + _, err := runtime.Pull(ctx, "quay.io/libpod/alpine:latest", config.PullPolicyAlways, pullOptions) require.NoError(t, err) - _, err = runtime.Pull(ctx, "docker.io/library/busybox:latest", config.PullPolicyAlways, pullOptions) + _, err = runtime.Pull(ctx, "quay.io/libpod/busybox:latest", config.PullPolicyAlways, pullOptions) require.NoError(t, err) // Save the two images into a multi-image archive. This way, we can @@ -32,7 +32,7 @@ func TestSave(t *testing.T) { require.NoError(t, err) imageCache.Close() defer os.Remove(imageCache.Name()) - err = runtime.Save(ctx, []string{"alpine", "busybox"}, "docker-archive", imageCache.Name(), saveOptions) + err = runtime.Save(ctx, []string{"alpine", "busybox"}, "compat-archive", imageCache.Name(), saveOptions) require.NoError(t, err) loadOptions := &LoadOptions{} @@ -58,13 +58,18 @@ func TestSave(t *testing.T) { {[]string{"busybox"}, nil, "oci-archive", false, false}, // oci-archive doesn't support multi-image archives {[]string{"busybox", "alpine"}, nil, "oci-archive", false, true}, - // docker + // compat {[]string{"busybox"}, nil, "docker-archive", false, false}, + {[]string{"busybox"}, nil, "compat-archive", false, false}, {[]string{"busybox"}, []string{"localhost/tag:1", "quay.io/repo/image:tag"}, "docker-archive", false, false}, + {[]string{"busybox"}, []string{"localhost/tag:1", "quay.io/repo/image:tag"}, "compat-archive", false, false}, {[]string{"busybox"}, nil, "docker-dir", true, false}, + {[]string{"busybox"}, nil, "dir", true, false}, {[]string{"busybox", "alpine"}, nil, "docker-archive", false, false}, + {[]string{"busybox", "alpine"}, nil, "compat-archive", false, false}, // additional tags and multi-images conflict {[]string{"busybox", "alpine"}, []string{"tag"}, "docker-archive", false, true}, + {[]string{"busybox", "alpine"}, []string{"tag"}, "compat-archive", false, true}, } { // First clean up all images and load the cache. _, rmErrors := runtime.RemoveImages(ctx, nil, nil) @@ -100,7 +105,7 @@ func TestSave(t *testing.T) { // Now make sure that all specified names (and tags) resolve to // an image the local containers storage. Note that names are // only preserved in archives. - if strings.HasSuffix(test.format, "-dir") { + if strings.HasSuffix(test.format, "dir") { continue } _, err = runtime.ListImages(ctx, namesAndTags, nil)