diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/02ea786cb1ff44d997661886a4186cbd8a1dc466938712bf7281379209476022 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/02ea786cb1ff44d997661886a4186cbd8a1dc466938712bf7281379209476022 new file mode 100644 index 0000000000..add1797963 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/02ea786cb1ff44d997661886a4186cbd8a1dc466938712bf7281379209476022 @@ -0,0 +1 @@ +insert binary content here #26559 diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/0dc27f36a618c110ae851662c13283e9fbc1b5a5de003befc4bcefa5a05d2eef b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/0dc27f36a618c110ae851662c13283e9fbc1b5a5de003befc4bcefa5a05d2eef new file mode 100644 index 0000000000..b3a7a96cd0 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/0dc27f36a618c110ae851662c13283e9fbc1b5a5de003befc4bcefa5a05d2eef @@ -0,0 +1,16 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": { + "mediaType": "application/vnd.oci.image.config.v1+json", + "digest": "sha256:913cf3a39d377faf89ed388ad913a318a390488c9f34c46e43424795cdabffe8", + "size": 585 + }, + "layers": [ + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:a6f737ac2b84bc463f2ff721af39588c69646c82f79f3808236178e02e35b922", + "size": 33 + } + ] +} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/39c524417bb4228f9fcb0aef43a680b5fd6b9f3a1df2fd50509d047e47dad8be b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/39c524417bb4228f9fcb0aef43a680b5fd6b9f3a1df2fd50509d047e47dad8be new file mode 100644 index 0000000000..8b7c8e3682 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/39c524417bb4228f9fcb0aef43a680b5fd6b9f3a1df2fd50509d047e47dad8be @@ -0,0 +1,16 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": { + "mediaType": "application/vnd.oci.image.config.v1+json", + "digest": "sha256:f732172ad8d2a666550fa3ec37a5153d59acc95744562ae64cf62ded46de101a", + "size": 583 + }, + "layers": [ + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:02ea786cb1ff44d997661886a4186cbd8a1dc466938712bf7281379209476022", + "size": 34 + } + ] +} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/557ac7d133b7770216a8101268640edf4e88beab1b4e1e1bfc9b1891a1cab861 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/557ac7d133b7770216a8101268640edf4e88beab1b4e1e1bfc9b1891a1cab861 new file mode 100644 index 0000000000..19c1c1276f --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/557ac7d133b7770216a8101268640edf4e88beab1b4e1e1bfc9b1891a1cab861 @@ -0,0 +1 @@ +insert binary content here #9811 diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/5b2aba4d3c27bc6493633d0ec446b25c8d0a5c9cfe99894bcdff0aee80813805 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/5b2aba4d3c27bc6493633d0ec446b25c8d0a5c9cfe99894bcdff0aee80813805 new file mode 100644 index 0000000000..aba2333ead --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/5b2aba4d3c27bc6493633d0ec446b25c8d0a5c9cfe99894bcdff0aee80813805 @@ -0,0 +1,16 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": { + "mediaType": "application/vnd.oci.image.config.v1+json", + "digest": "sha256:df11bc189adeb50dadb3291a3a7f2c34b36e0efdba0df70f2c8a2d761b215cde", + "size": 585 + }, + "layers": [ + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:986315a0e599fac2b80eb31db2124dab8d3de04d7ca98b254999bd913c1f73fe", + "size": 33 + } + ] +} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/7ffdfe7d276286b39a203dcc247949cf47c91d2d5e10a53a675c0962ed9e4402 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/7ffdfe7d276286b39a203dcc247949cf47c91d2d5e10a53a675c0962ed9e4402 new file mode 100644 index 0000000000..f21c274635 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/7ffdfe7d276286b39a203dcc247949cf47c91d2d5e10a53a675c0962ed9e4402 @@ -0,0 +1 @@ +{"created":"2023-08-07T19:38:34.915445772Z","architecture":"386","os":"linux","config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"]},"rootfs":{"type":"layers","diff_ids":["sha256:53bfdd548f8566a059cd188348b202a50fb9d39ce80eb5b8f0c670dfa9bc6569"]},"history":[{"created":"2023-08-07T19:38:34.803529816Z","created_by":"/bin/sh -c #(nop) ADD file:c06b4f6991638e506d4d0a4d70c4a78ba30b971767802af4c6b837cdf59d4303 in / "},{"created":"2023-08-07T19:38:34.915445772Z","created_by":"/bin/sh -c #(nop) CMD [\"/bin/sh\"]","empty_layer":true}]} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/861d3c014b0e3edcf80e6221247d6b2921a4f892feb9bafe9515b9975b78c44f b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/861d3c014b0e3edcf80e6221247d6b2921a4f892feb9bafe9515b9975b78c44f new file mode 100644 index 0000000000..85617bd7ac --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/861d3c014b0e3edcf80e6221247d6b2921a4f892feb9bafe9515b9975b78c44f @@ -0,0 +1,24 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.index.v1+json", + "manifests": [ + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:39c524417bb4228f9fcb0aef43a680b5fd6b9f3a1df2fd50509d047e47dad8be", + "size": 525, + "platform": { + "architecture": "amd64", + "os": "linux" + } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:be6036f9b6a4e120a04868c47f1b8674f58b2fe5e410cba9f585a13ca8946cf0", + "size": 525, + "platform": { + "architecture": "386", + "os": "linux" + } + } + ] +} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/913cf3a39d377faf89ed388ad913a318a390488c9f34c46e43424795cdabffe8 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/913cf3a39d377faf89ed388ad913a318a390488c9f34c46e43424795cdabffe8 new file mode 100644 index 0000000000..ebe323d4df --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/913cf3a39d377faf89ed388ad913a318a390488c9f34c46e43424795cdabffe8 @@ -0,0 +1 @@ +{"created":"2023-08-07T19:20:20.894140623Z","architecture":"amd64","os":"linux","config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"]},"rootfs":{"type":"layers","diff_ids":["sha256:4693057ce2364720d39e57e85a5b8e0bd9ac3573716237736d6470ec5b7b7230"]},"history":[{"created":"2023-08-07T19:20:20.71894984Z","created_by":"/bin/sh -c #(nop) ADD file:32ff5e7a78b890996ee4681cc0a26185d3e9acdb4eb1e2aaccb2411f922fed6b in / "},{"created":"2023-08-07T19:20:20.894140623Z","created_by":"/bin/sh -c #(nop) CMD [\"/bin/sh\"]","empty_layer":true}]} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/93cbd11a4f41467a0409b975499ae711bc6f8222de38d9f1b5a4097583195ad5 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/93cbd11a4f41467a0409b975499ae711bc6f8222de38d9f1b5a4097583195ad5 new file mode 100644 index 0000000000..ccf025c98f --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/93cbd11a4f41467a0409b975499ae711bc6f8222de38d9f1b5a4097583195ad5 @@ -0,0 +1,16 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": { + "mediaType": "application/vnd.oci.image.config.v1+json", + "digest": "sha256:913cf3a39d377faf89ed388ad913a318a390488c9f34c46e43424795cdabffe8", + "size": 584 + }, + "layers": [ + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:557ac7d133b7770216a8101268640edf4e88beab1b4e1e1bfc9b1891a1cab861", + "size": 33 + } + ] +} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/986315a0e599fac2b80eb31db2124dab8d3de04d7ca98b254999bd913c1f73fe b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/986315a0e599fac2b80eb31db2124dab8d3de04d7ca98b254999bd913c1f73fe new file mode 100644 index 0000000000..a0cd5aab0e --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/986315a0e599fac2b80eb31db2124dab8d3de04d7ca98b254999bd913c1f73fe @@ -0,0 +1 @@ +insert binary content here #7959 diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/a2f798327b3f25e3eff54badcb769953de235e62e3e32051d57a5e66246de4a1 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/a2f798327b3f25e3eff54badcb769953de235e62e3e32051d57a5e66246de4a1 new file mode 100644 index 0000000000..aeecdfac4e --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/a2f798327b3f25e3eff54badcb769953de235e62e3e32051d57a5e66246de4a1 @@ -0,0 +1,24 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.index.v1+json", + "manifests": [ + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:93cbd11a4f41467a0409b975499ae711bc6f8222de38d9f1b5a4097583195ad5", + "size": 525, + "platform": { + "architecture": "amd64", + "os": "linux" + } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:f6d60fd529b234d3e28837e15294d935f55da58ce57c4f9218cad38d0be82ce3", + "size": 525, + "platform": { + "architecture": "386", + "os": "linux" + } + } + ] +} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/a6f737ac2b84bc463f2ff721af39588c69646c82f79f3808236178e02e35b922 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/a6f737ac2b84bc463f2ff721af39588c69646c82f79f3808236178e02e35b922 new file mode 100644 index 0000000000..f26e504a8e --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/a6f737ac2b84bc463f2ff721af39588c69646c82f79f3808236178e02e35b922 @@ -0,0 +1 @@ +insert binary content here #1234 diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/aab808b283c3f654d84358a40ce8766ecd552249305141de88f0ca61f3d1368f b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/aab808b283c3f654d84358a40ce8766ecd552249305141de88f0ca61f3d1368f new file mode 100644 index 0000000000..e1d45d3569 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/aab808b283c3f654d84358a40ce8766ecd552249305141de88f0ca61f3d1368f @@ -0,0 +1 @@ +{"created":"2023-08-07T19:38:27.007952531Z","architecture":"386","os":"linux","config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"]},"rootfs":{"type":"layers","diff_ids":["sha256:f05b0759429ba12d5fda46c196f253cc1cab8f56cd874e9e7be674fc1b8337de"]},"history":[{"created":"2023-08-07T19:38:26.69689892Z","created_by":"/bin/sh -c #(nop) ADD file:4b33c52e11b19fde30197c62ead0b77bde28d34edaa08346a5302cd892d3cebe in / "},{"created":"2023-08-07T19:38:27.007952531Z","created_by":"/bin/sh -c #(nop) CMD [\"/bin/sh\"]","empty_layer":true}]} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/be6036f9b6a4e120a04868c47f1b8674f58b2fe5e410cba9f585a13ca8946cf0 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/be6036f9b6a4e120a04868c47f1b8674f58b2fe5e410cba9f585a13ca8946cf0 new file mode 100644 index 0000000000..c2d027aa76 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/be6036f9b6a4e120a04868c47f1b8674f58b2fe5e410cba9f585a13ca8946cf0 @@ -0,0 +1,16 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": { + "mediaType": "application/vnd.oci.image.config.v1+json", + "digest": "sha256:7ffdfe7d276286b39a203dcc247949cf47c91d2d5e10a53a675c0962ed9e4402", + "size": 583 + }, + "layers": [ + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:e2f7e0374fd6a03d9c373f4d9a0c7802045cc3ddcc1433e89d83b81fa7007242", + "size": 33 + } + ] +} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/df11bc189adeb50dadb3291a3a7f2c34b36e0efdba0df70f2c8a2d761b215cde b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/df11bc189adeb50dadb3291a3a7f2c34b36e0efdba0df70f2c8a2d761b215cde new file mode 100644 index 0000000000..1ff4ad5415 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/df11bc189adeb50dadb3291a3a7f2c34b36e0efdba0df70f2c8a2d761b215cde @@ -0,0 +1 @@ +{"created":"2023-08-07T19:20:26.426857961Z","architecture":"amd64","os":"linux","config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"]},"rootfs":{"type":"layers","diff_ids":["sha256:36b50b131297b8860da51b2d2b24bb4c08dfbdf2789b08e3cc0f187c98637a19"]},"history":[{"created":"2023-08-07T19:20:26.326707843Z","created_by":"/bin/sh -c #(nop) ADD file:6dd87346b8be240b21b4f4d9296253bf0d28b6579aa52d2118872e3936963b6b in / "},{"created":"2023-08-07T19:20:26.426857961Z","created_by":"/bin/sh -c #(nop) CMD [\"/bin/sh\"]","empty_layer":true}]} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/e19729d5a968c71b4b691d60f4a6f85f93c303bb88635dcfef36e23b76cb7b3a b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/e19729d5a968c71b4b691d60f4a6f85f93c303bb88635dcfef36e23b76cb7b3a new file mode 100644 index 0000000000..832c1185d8 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/e19729d5a968c71b4b691d60f4a6f85f93c303bb88635dcfef36e23b76cb7b3a @@ -0,0 +1 @@ +insert binary content here #28017 diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/e2f7e0374fd6a03d9c373f4d9a0c7802045cc3ddcc1433e89d83b81fa7007242 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/e2f7e0374fd6a03d9c373f4d9a0c7802045cc3ddcc1433e89d83b81fa7007242 new file mode 100644 index 0000000000..a18eab8965 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/e2f7e0374fd6a03d9c373f4d9a0c7802045cc3ddcc1433e89d83b81fa7007242 @@ -0,0 +1 @@ +insert binary content here #4794 diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/f6d60fd529b234d3e28837e15294d935f55da58ce57c4f9218cad38d0be82ce3 b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/f6d60fd529b234d3e28837e15294d935f55da58ce57c4f9218cad38d0be82ce3 new file mode 100644 index 0000000000..fb85ad20ac --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/f6d60fd529b234d3e28837e15294d935f55da58ce57c4f9218cad38d0be82ce3 @@ -0,0 +1,16 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": { + "mediaType": "application/vnd.oci.image.config.v1+json", + "digest": "sha256:aab808b283c3f654d84358a40ce8766ecd552249305141de88f0ca61f3d1368f", + "size": 582 + }, + "layers": [ + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:e19729d5a968c71b4b691d60f4a6f85f93c303bb88635dcfef36e23b76cb7b3a", + "size": 34 + } + ] +} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/f732172ad8d2a666550fa3ec37a5153d59acc95744562ae64cf62ded46de101a b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/f732172ad8d2a666550fa3ec37a5153d59acc95744562ae64cf62ded46de101a new file mode 100644 index 0000000000..016b01bc3d --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/blobs/sha256/f732172ad8d2a666550fa3ec37a5153d59acc95744562ae64cf62ded46de101a @@ -0,0 +1 @@ +{"created":"2023-08-07T19:20:31.99661329Z","architecture":"amd64","os":"linux","config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"]},"rootfs":{"type":"layers","diff_ids":["sha256:0e182002b05f2ab123995821ef14f1cda765a0c31f7a6d260221558f6466535e"]},"history":[{"created":"2023-08-07T19:20:31.893185238Z","created_by":"/bin/sh -c #(nop) ADD file:76d829bbce3dd420a8419919b0916c0fda917011d1e6752ca5b9e53d5ca890a6 in / "},{"created":"2023-08-07T19:20:31.99661329Z","created_by":"/bin/sh -c #(nop) CMD [\"/bin/sh\"]","empty_layer":true}]} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/index.json b/oci/layout/fixtures/delete_image_multiple_images/index.json new file mode 100644 index 0000000000..d781143f54 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/index.json @@ -0,0 +1,61 @@ +{ + "schemaVersion": 2, + "manifests": [ + { + "mediaType": "application/vnd.oci.image.index.v1+json", + "digest": "sha256:a2f798327b3f25e3eff54badcb769953de235e62e3e32051d57a5e66246de4a1", + "size": 759, + "annotations": { + "org.opencontainers.image.ref.name": "latest" + } + }, + { + "mediaType": "application/vnd.oci.image.index.v1+json", + "digest": "sha256:a2f798327b3f25e3eff54badcb769953de235e62e3e32051d57a5e66246de4a1", + "size": 759, + "annotations": { + "org.opencontainers.image.ref.name": "3.18.3" + } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:93cbd11a4f41467a0409b975499ae711bc6f8222de38d9f1b5a4097583195ad5", + "size": 525, + "annotations": { + "org.opencontainers.image.ref.name": "3" + } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:93cbd11a4f41467a0409b975499ae711bc6f8222de38d9f1b5a4097583195ad5", + "size": 525, + "annotations": { + "org.opencontainers.image.ref.name": "3.18" + } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:5b2aba4d3c27bc6493633d0ec446b25c8d0a5c9cfe99894bcdff0aee80813805", + "size": 525, + "annotations": { + "org.opencontainers.image.ref.name": "3.17.5" + } + }, + { + "mediaType": "application/vnd.oci.image.index.v1+json", + "digest": "sha256:861d3c014b0e3edcf80e6221247d6b2921a4f892feb9bafe9515b9975b78c44f", + "size": 759, + "annotations": { + "org.opencontainers.image.ref.name": "3.16.7" + } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:0dc27f36a618c110ae851662c13283e9fbc1b5a5de003befc4bcefa5a05d2eef", + "size": 525, + "annotations": { + "org.opencontainers.image.ref.name": "1.0.0" + } + } + ] +} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_multiple_images/info.txt b/oci/layout/fixtures/delete_image_multiple_images/info.txt new file mode 100644 index 0000000000..4ec2b148c9 --- /dev/null +++ b/oci/layout/fixtures/delete_image_multiple_images/info.txt @@ -0,0 +1,61 @@ +This is tree representation of the fixture to help writing the tests: + +7 references in the index, 10 descriptors and 19 blobs in the blob directory + +index.json +│ +├── 3.17.5 +│ └── manifest: 5b2aba4d3c27bc6493633d0ec446b25c8d0a5c9cfe99894bcdff0aee80813805 +│ config: df11bc189adeb50dadb3291a3a7f2c34b36e0efdba0df70f2c8a2d761b215cde +│ layers: 986315a0e599fac2b80eb31db2124dab8d3de04d7ca98b254999bd913c1f73fe +│ +├── 3.18 +│ └── manifest: 93cbd11a4f41467a0409b975499ae711bc6f8222de38d9f1b5a4097583195ad5 +│ config: 913cf3a39d377faf89ed388ad913a318a390488c9f34c46e43424795cdabffe8 +│ layers: 557ac7d133b7770216a8101268640edf4e88beab1b4e1e1bfc9b1891a1cab861 +│ +├── 3 +│ └── manifest: 93cbd11a4f41467a0409b975499ae711bc6f8222de38d9f1b5a4097583195ad5 +│ config: 913cf3a39d377faf89ed388ad913a318a390488c9f34c46e43424795cdabffe8 +│ layers: 557ac7d133b7770216a8101268640edf4e88beab1b4e1e1bfc9b1891a1cab861 +│ +├── 1.0.0 +│ └── manifest: 0dc27f36a618c110ae851662c13283e9fbc1b5a5de003befc4bcefa5a05d2eef +│ config: 913cf3a39d377faf89ed388ad913a318a390488c9f34c46e43424795cdabffe8 +│ layers: a6f737ac2b84bc463f2ff721af39588c69646c82f79f3808236178e02e35b922 +│ +├── latest +│ └── index: a2f798327b3f25e3eff54badcb769953de235e62e3e32051d57a5e66246de4a1 +│ ├── linux/am64 +│ │ └── manifest: 93cbd11a4f41467a0409b975499ae711bc6f8222de38d9f1b5a4097583195ad5 +│ │ config: 913cf3a39d377faf89ed388ad913a318a390488c9f34c46e43424795cdabffe8 +│ │ layers: 557ac7d133b7770216a8101268640edf4e88beab1b4e1e1bfc9b1891a1cab861 +│ │ +│ └── linux/386 +│ └── manifest: f6d60fd529b234d3e28837e15294d935f55da58ce57c4f9218cad38d0be82ce3 +│ config: aab808b283c3f654d84358a40ce8766ecd552249305141de88f0ca61f3d1368f +│ layers: e19729d5a968c71b4b691d60f4a6f85f93c303bb88635dcfef36e23b76cb7b3a +│ +├── 3.18.3 +│ └── index: a2f798327b3f25e3eff54badcb769953de235e62e3e32051d57a5e66246de4a1 +│ ├── linux/am64 +│ │ └── manifest: 93cbd11a4f41467a0409b975499ae711bc6f8222de38d9f1b5a4097583195ad5 +│ │ config: 913cf3a39d377faf89ed388ad913a318a390488c9f34c46e43424795cdabffe8 +│ │ layers: 557ac7d133b7770216a8101268640edf4e88beab1b4e1e1bfc9b1891a1cab861 +│ │ +│ └── linux/386 +│ └── manifest: f6d60fd529b234d3e28837e15294d935f55da58ce57c4f9218cad38d0be82ce3 +│ config: aab808b283c3f654d84358a40ce8766ecd552249305141de88f0ca61f3d1368f +│ layers: e19729d5a968c71b4b691d60f4a6f85f93c303bb88635dcfef36e23b76cb7b3a +│ +├── 3.16.7 +│ └── index: 861d3c014b0e3edcf80e6221247d6b2921a4f892feb9bafe9515b9975b78c44f +│ ├── linux/am64 +│ │ └── manifest: 39c524417bb4228f9fcb0aef43a680b5fd6b9f3a1df2fd50509d047e47dad8be +│ │ config: f732172ad8d2a666550fa3ec37a5153d59acc95744562ae64cf62ded46de101a +│ │ layers: 02ea786cb1ff44d997661886a4186cbd8a1dc466938712bf7281379209476022 +│ │ +│ └── linux/386 +│ └── manifest: be6036f9b6a4e120a04868c47f1b8674f58b2fe5e410cba9f585a13ca8946cf0 +│ config: 7ffdfe7d276286b39a203dcc247949cf47c91d2d5e10a53a675c0962ed9e4402 +│ layers: e2f7e0374fd6a03d9c373f4d9a0c7802045cc3ddcc1433e89d83b81fa7007242 diff --git a/oci/layout/fixtures/delete_image/oci-layout b/oci/layout/fixtures/delete_image_multiple_images/oci-layout similarity index 100% rename from oci/layout/fixtures/delete_image/oci-layout rename to oci/layout/fixtures/delete_image_multiple_images/oci-layout diff --git a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e b/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e deleted file mode 100644 index 311858b5d4..0000000000 --- a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e +++ /dev/null @@ -1,30 +0,0 @@ -{ - "created": "2019-01-30T22:20:12.031064202Z", - "architecture": "amd64", - "os": "linux", - "config": { - "Env": [ - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - ], - "Cmd": [ - "/bin/sh" - ] - }, - "rootfs": { - "type": "layers", - "diff_ids": [ - "sha256:2f0b1957d1f7074296e0d6388139b7a968e8c051f8b6227f3610757f7407af05" - ] - }, - "history": [ - { - "created": "2019-01-30T22:20:11.788749685Z", - "created_by": "/bin/sh -c #(nop) ADD file:3b4be7a9f665764de3067907af34cd36e3755c930cd894821d03d46ebb329812 in / " - }, - { - "created": "2019-01-30T22:20:12.031064202Z", - "created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]", - "empty_layer": true - } - ] -} diff --git a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/9a48d58d496b700f364686fbfbb2141ff5f0f25b033078a4c11fe597770b6fab b/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/9a48d58d496b700f364686fbfbb2141ff5f0f25b033078a4c11fe597770b6fab deleted file mode 100644 index 1bbffe7cf9..0000000000 --- a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/9a48d58d496b700f364686fbfbb2141ff5f0f25b033078a4c11fe597770b6fab +++ /dev/null @@ -1,16 +0,0 @@ -{ - "schemaVersion": 2, - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "config": { - "mediaType": "application/vnd.oci.image.config.v1+json", - "digest": "sha256:8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e", - "size": 585 - }, - "layers": [ - { - "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", - "digest": "sha256:d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545", - "size": 34 - } - ] -} diff --git a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/bc584603ae5ca55d701f5134a0e5699056536885580ee929945bcbfeaf2633e6 b/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/bc584603ae5ca55d701f5134a0e5699056536885580ee929945bcbfeaf2633e6 deleted file mode 100644 index 3a1e4b21e5..0000000000 --- a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/bc584603ae5ca55d701f5134a0e5699056536885580ee929945bcbfeaf2633e6 +++ /dev/null @@ -1 +0,0 @@ -insert binary content here #24993 diff --git a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545 b/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545 deleted file mode 100644 index 1cfb0c4c23..0000000000 --- a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545 +++ /dev/null @@ -1 +0,0 @@ -insert binary content here #23287 diff --git a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/f082a2f88d9405f9d583e5038c76290d10dbefdb9b2137301c1e867f6f43cff6 b/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/f082a2f88d9405f9d583e5038c76290d10dbefdb9b2137301c1e867f6f43cff6 deleted file mode 100644 index 75a476f2d0..0000000000 --- a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/f082a2f88d9405f9d583e5038c76290d10dbefdb9b2137301c1e867f6f43cff6 +++ /dev/null @@ -1,16 +0,0 @@ -{ - "schemaVersion": 2, - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "config": { - "mediaType": "application/vnd.oci.image.config.v1+json", - "digest": "sha256:a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423", - "size": 585 - }, - "layers": [ - { - "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", - "digest": "sha256:bc584603ae5ca55d701f5134a0e5699056536885580ee929945bcbfeaf2633e6", - "size": 34 - } - ] -} diff --git a/oci/layout/fixtures/delete_image_multipleimages/index.json b/oci/layout/fixtures/delete_image_multipleimages/index.json deleted file mode 100644 index 74e59f75e1..0000000000 --- a/oci/layout/fixtures/delete_image_multipleimages/index.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "schemaVersion": 2, - "manifests": [ - { - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:9a48d58d496b700f364686fbfbb2141ff5f0f25b033078a4c11fe597770b6fab", - "size": 405, - "annotations": { - "org.opencontainers.image.ref.name": "3.2" - } - }, - { - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:f082a2f88d9405f9d583e5038c76290d10dbefdb9b2137301c1e867f6f43cff6", - "size": 405, - "annotations": { - "org.opencontainers.image.ref.name": "3.10.2" - } - } - ] -} diff --git a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/4a6da698b869046086d0e6ba846f8b931cb33bbaa5c68025b4fd55f67a4f0513 b/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/4a6da698b869046086d0e6ba846f8b931cb33bbaa5c68025b4fd55f67a4f0513 deleted file mode 100644 index 08eb088e75..0000000000 --- a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/4a6da698b869046086d0e6ba846f8b931cb33bbaa5c68025b4fd55f67a4f0513 +++ /dev/null @@ -1,21 +0,0 @@ -{ - "schemaVersion": 2, - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "config": { - "mediaType": "application/vnd.oci.image.config.v1+json", - "digest": "sha256:a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423", - "size": 585 - }, - "layers": [ - { - "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", - "digest": "sha256:0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc", - "size": 33 - }, - { - "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", - "digest": "sha256:d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545", - "size": 34 - } - ] -} diff --git a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e b/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e deleted file mode 100644 index 311858b5d4..0000000000 --- a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e +++ /dev/null @@ -1,30 +0,0 @@ -{ - "created": "2019-01-30T22:20:12.031064202Z", - "architecture": "amd64", - "os": "linux", - "config": { - "Env": [ - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - ], - "Cmd": [ - "/bin/sh" - ] - }, - "rootfs": { - "type": "layers", - "diff_ids": [ - "sha256:2f0b1957d1f7074296e0d6388139b7a968e8c051f8b6227f3610757f7407af05" - ] - }, - "history": [ - { - "created": "2019-01-30T22:20:11.788749685Z", - "created_by": "/bin/sh -c #(nop) ADD file:3b4be7a9f665764de3067907af34cd36e3755c930cd894821d03d46ebb329812 in / " - }, - { - "created": "2019-01-30T22:20:12.031064202Z", - "created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]", - "empty_layer": true - } - ] -} diff --git a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/9a48d58d496b700f364686fbfbb2141ff5f0f25b033078a4c11fe597770b6fab b/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/9a48d58d496b700f364686fbfbb2141ff5f0f25b033078a4c11fe597770b6fab deleted file mode 100644 index 1bbffe7cf9..0000000000 --- a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/9a48d58d496b700f364686fbfbb2141ff5f0f25b033078a4c11fe597770b6fab +++ /dev/null @@ -1,16 +0,0 @@ -{ - "schemaVersion": 2, - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "config": { - "mediaType": "application/vnd.oci.image.config.v1+json", - "digest": "sha256:8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e", - "size": 585 - }, - "layers": [ - { - "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", - "digest": "sha256:d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545", - "size": 34 - } - ] -} diff --git a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 b/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 deleted file mode 100644 index f0f06201be..0000000000 --- a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 +++ /dev/null @@ -1,30 +0,0 @@ -{ - "created": "2019-08-20T20:19:55.211423266Z", - "architecture": "amd64", - "os": "linux", - "config": { - "Env": [ - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - ], - "Cmd": [ - "/bin/sh" - ] - }, - "rootfs": { - "type": "layers", - "diff_ids": [ - "sha256:03901b4a2ea88eeaad62dbe59b072b28b6efa00491962b8741081c5df50c65e0" - ] - }, - "history": [ - { - "created": "2019-08-20T20:19:55.062606894Z", - "created_by": "/bin/sh -c #(nop) ADD file:fe64057fbb83dccb960efabbf1cd8777920ef279a7fa8dbca0a8801c651bdf7c in / " - }, - { - "created": "2019-08-20T20:19:55.211423266Z", - "created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]", - "empty_layer": true - } - ] -} diff --git a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/b2ff1c27b718b90910711aeda5e02ebbf4440659edd589cc458b3039ea91b35f b/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/b2ff1c27b718b90910711aeda5e02ebbf4440659edd589cc458b3039ea91b35f deleted file mode 100644 index 6479e8daf5..0000000000 --- a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/b2ff1c27b718b90910711aeda5e02ebbf4440659edd589cc458b3039ea91b35f +++ /dev/null @@ -1,18 +0,0 @@ -{ - "schemaVersion": 2, - "manifests": [ - { - "mediaType": "application/vnd.oci.image.index.v1+json", - "digest": "sha256:fbe294d1b627d6ee3c119d558dad8b1c4542cbc51c49ec45dd638921bc5921d0", - "size": 1542 - }, - { - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:9a48d58d496b700f364686fbfbb2141ff5f0f25b033078a4c11fe597770b6fab", - "size": 405, - "annotations": { - "org.opencontainers.image.ref.name": "3.2" - } - } - ] -} diff --git a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545 b/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545 deleted file mode 100644 index 1cfb0c4c23..0000000000 --- a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545 +++ /dev/null @@ -1 +0,0 @@ -insert binary content here #23287 diff --git a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/fbe294d1b627d6ee3c119d558dad8b1c4542cbc51c49ec45dd638921bc5921d0 b/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/fbe294d1b627d6ee3c119d558dad8b1c4542cbc51c49ec45dd638921bc5921d0 deleted file mode 100644 index 930c0cd29b..0000000000 --- a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/fbe294d1b627d6ee3c119d558dad8b1c4542cbc51c49ec45dd638921bc5921d0 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "schemaVersion": 2, - "manifests": [ - { - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:4a6da698b869046086d0e6ba846f8b931cb33bbaa5c68025b4fd55f67a4f0513", - "size": 405, - "annotations": { - "org.opencontainers.image.ref.name": "latest" - } - } - ] -} diff --git a/oci/layout/fixtures/delete_image_nestedindex/index.json b/oci/layout/fixtures/delete_image_nestedindex/index.json deleted file mode 100644 index 6dab5e22af..0000000000 --- a/oci/layout/fixtures/delete_image_nestedindex/index.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "schemaVersion": 2, - "manifests": [ - { - "mediaType": "application/vnd.oci.image.index.v1+json", - "digest": "sha256:b2ff1c27b718b90910711aeda5e02ebbf4440659edd589cc458b3039ea91b35f", - "size": 1542 - } - ] -} diff --git a/oci/layout/fixtures/delete_image/blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc b/oci/layout/fixtures/delete_image_only_one_image/blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc similarity index 100% rename from oci/layout/fixtures/delete_image/blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc rename to oci/layout/fixtures/delete_image_only_one_image/blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc diff --git a/oci/layout/fixtures/delete_image/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 b/oci/layout/fixtures/delete_image_only_one_image/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 similarity index 100% rename from oci/layout/fixtures/delete_image/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 rename to oci/layout/fixtures/delete_image_only_one_image/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 diff --git a/oci/layout/fixtures/delete_image/blobs/sha256/eaa95f3cfaac07c8a5153eb77c933269586ad0226c83405776be08547e4d2a18 b/oci/layout/fixtures/delete_image_only_one_image/blobs/sha256/eaa95f3cfaac07c8a5153eb77c933269586ad0226c83405776be08547e4d2a18 similarity index 100% rename from oci/layout/fixtures/delete_image/blobs/sha256/eaa95f3cfaac07c8a5153eb77c933269586ad0226c83405776be08547e4d2a18 rename to oci/layout/fixtures/delete_image_only_one_image/blobs/sha256/eaa95f3cfaac07c8a5153eb77c933269586ad0226c83405776be08547e4d2a18 diff --git a/oci/layout/fixtures/delete_image/index.json b/oci/layout/fixtures/delete_image_only_one_image/index.json similarity index 100% rename from oci/layout/fixtures/delete_image/index.json rename to oci/layout/fixtures/delete_image_only_one_image/index.json diff --git a/oci/layout/fixtures/delete_image_multipleimages/oci-layout b/oci/layout/fixtures/delete_image_only_one_image/oci-layout similarity index 100% rename from oci/layout/fixtures/delete_image_multipleimages/oci-layout rename to oci/layout/fixtures/delete_image_only_one_image/oci-layout diff --git a/oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 b/oci/layout/fixtures/delete_image_shared_blobs_dir/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 similarity index 100% rename from oci/layout/fixtures/delete_image_multipleimages/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 rename to oci/layout/fixtures/delete_image_shared_blobs_dir/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 diff --git a/oci/layout/fixtures/delete_image_sharedblobsdir/index.json b/oci/layout/fixtures/delete_image_shared_blobs_dir/index.json similarity index 100% rename from oci/layout/fixtures/delete_image_sharedblobsdir/index.json rename to oci/layout/fixtures/delete_image_shared_blobs_dir/index.json diff --git a/oci/layout/fixtures/delete_image_nestedindex/oci-layout b/oci/layout/fixtures/delete_image_shared_blobs_dir/oci-layout similarity index 100% rename from oci/layout/fixtures/delete_image_nestedindex/oci-layout rename to oci/layout/fixtures/delete_image_shared_blobs_dir/oci-layout diff --git a/oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc b/oci/layout/fixtures/delete_image_shared_blobs_dir/shared_blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc similarity index 100% rename from oci/layout/fixtures/delete_image_nestedindex/blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc rename to oci/layout/fixtures/delete_image_shared_blobs_dir/shared_blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc diff --git a/oci/layout/fixtures/delete_image_sharedblobsdir/shared_blobs/sha256/eaa95f3cfaac07c8a5153eb77c933269586ad0226c83405776be08547e4d2a18 b/oci/layout/fixtures/delete_image_shared_blobs_dir/shared_blobs/sha256/eaa95f3cfaac07c8a5153eb77c933269586ad0226c83405776be08547e4d2a18 similarity index 100% rename from oci/layout/fixtures/delete_image_sharedblobsdir/shared_blobs/sha256/eaa95f3cfaac07c8a5153eb77c933269586ad0226c83405776be08547e4d2a18 rename to oci/layout/fixtures/delete_image_shared_blobs_dir/shared_blobs/sha256/eaa95f3cfaac07c8a5153eb77c933269586ad0226c83405776be08547e4d2a18 diff --git a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/11afdbc1155db5c42356e8304f42664a0b7d6b0e7cbe72d7a7d72c5dd4e11389 b/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/11afdbc1155db5c42356e8304f42664a0b7d6b0e7cbe72d7a7d72c5dd4e11389 deleted file mode 100644 index c8f52d491b..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/11afdbc1155db5c42356e8304f42664a0b7d6b0e7cbe72d7a7d72c5dd4e11389 +++ /dev/null @@ -1,16 +0,0 @@ -{ - "schemaVersion": 2, - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "config": { - "mediaType": "application/vnd.oci.image.config.v1+json", - "digest": "sha256:a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423", - "size": 585 - }, - "layers": [ - { - "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", - "digest": "sha256:d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545", - "size": 34 - } - ] -} diff --git a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/2363edaccd5115dad0462eac535496a0b7b661311d1fb8ed7a1f51368bfa9f3a b/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/2363edaccd5115dad0462eac535496a0b7b661311d1fb8ed7a1f51368bfa9f3a deleted file mode 100644 index 7d7f4a0108..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/2363edaccd5115dad0462eac535496a0b7b661311d1fb8ed7a1f51368bfa9f3a +++ /dev/null @@ -1,21 +0,0 @@ -{ - "schemaVersion": 2, - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "config": { - "mediaType": "application/vnd.oci.image.config.v1+json", - "digest": "sha256:8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e", - "size": 585 - }, - "layers": [ - { - "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", - "digest": "sha256:d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545", - "size": 34 - }, - { - "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", - "digest": "sha256:49b6418afb4ee08ba3956e4c344034c89a39ef1a451a55b44926ad9ee77e036b", - "size": 34 - } - ] -} diff --git a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/49b6418afb4ee08ba3956e4c344034c89a39ef1a451a55b44926ad9ee77e036b b/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/49b6418afb4ee08ba3956e4c344034c89a39ef1a451a55b44926ad9ee77e036b deleted file mode 100644 index 1b9ac01844..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/49b6418afb4ee08ba3956e4c344034c89a39ef1a451a55b44926ad9ee77e036b +++ /dev/null @@ -1 +0,0 @@ -insert binary content here #25145 diff --git a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e b/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e deleted file mode 100644 index 311858b5d4..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e +++ /dev/null @@ -1,30 +0,0 @@ -{ - "created": "2019-01-30T22:20:12.031064202Z", - "architecture": "amd64", - "os": "linux", - "config": { - "Env": [ - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - ], - "Cmd": [ - "/bin/sh" - ] - }, - "rootfs": { - "type": "layers", - "diff_ids": [ - "sha256:2f0b1957d1f7074296e0d6388139b7a968e8c051f8b6227f3610757f7407af05" - ] - }, - "history": [ - { - "created": "2019-01-30T22:20:11.788749685Z", - "created_by": "/bin/sh -c #(nop) ADD file:3b4be7a9f665764de3067907af34cd36e3755c930cd894821d03d46ebb329812 in / " - }, - { - "created": "2019-01-30T22:20:12.031064202Z", - "created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]", - "empty_layer": true - } - ] -} diff --git a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 b/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 deleted file mode 100644 index f0f06201be..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 +++ /dev/null @@ -1,30 +0,0 @@ -{ - "created": "2019-08-20T20:19:55.211423266Z", - "architecture": "amd64", - "os": "linux", - "config": { - "Env": [ - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - ], - "Cmd": [ - "/bin/sh" - ] - }, - "rootfs": { - "type": "layers", - "diff_ids": [ - "sha256:03901b4a2ea88eeaad62dbe59b072b28b6efa00491962b8741081c5df50c65e0" - ] - }, - "history": [ - { - "created": "2019-08-20T20:19:55.062606894Z", - "created_by": "/bin/sh -c #(nop) ADD file:fe64057fbb83dccb960efabbf1cd8777920ef279a7fa8dbca0a8801c651bdf7c in / " - }, - { - "created": "2019-08-20T20:19:55.211423266Z", - "created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]", - "empty_layer": true - } - ] -} diff --git a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/bbe511ad9c952a757e832933e151a10d2d011ea2222a4412219c5cf2723e6e50 b/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/bbe511ad9c952a757e832933e151a10d2d011ea2222a4412219c5cf2723e6e50 deleted file mode 100644 index 7ce3a4b83e..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/bbe511ad9c952a757e832933e151a10d2d011ea2222a4412219c5cf2723e6e50 +++ /dev/null @@ -1,16 +0,0 @@ -{ - "schemaVersion": 2, - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "config": { - "mediaType": "application/vnd.oci.image.config.v1+json", - "digest": "sha256:8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e", - "size": 585 - }, - "layers": [ - { - "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", - "digest": "sha256:bc584603ae5ca55d701f5134a0e5699056536885580ee929945bcbfeaf2633e6", - "size": 34 - } - ] -} diff --git a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/bc584603ae5ca55d701f5134a0e5699056536885580ee929945bcbfeaf2633e6 b/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/bc584603ae5ca55d701f5134a0e5699056536885580ee929945bcbfeaf2633e6 deleted file mode 100644 index 3a1e4b21e5..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/bc584603ae5ca55d701f5134a0e5699056536885580ee929945bcbfeaf2633e6 +++ /dev/null @@ -1 +0,0 @@ -insert binary content here #24993 diff --git a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545 b/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545 deleted file mode 100644 index 1cfb0c4c23..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobs/blobs/sha256/d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545 +++ /dev/null @@ -1 +0,0 @@ -insert binary content here #23287 diff --git a/oci/layout/fixtures/delete_image_sharedblobs/index.json b/oci/layout/fixtures/delete_image_sharedblobs/index.json deleted file mode 100644 index 712f226a73..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobs/index.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "schemaVersion": 2, - "manifests": [ - { - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:2363edaccd5115dad0462eac535496a0b7b661311d1fb8ed7a1f51368bfa9f3a", - "size": 405, - "annotations": { - "org.opencontainers.image.ref.name": "3.2" - } - }, - { - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:11afdbc1155db5c42356e8304f42664a0b7d6b0e7cbe72d7a7d72c5dd4e11389", - "size": 405, - "annotations": { - "org.opencontainers.image.ref.name": "3.10.2" - } - }, - { - "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:bbe511ad9c952a757e832933e151a10d2d011ea2222a4412219c5cf2723e6e50", - "size": 405, - "annotations": { - "org.opencontainers.image.ref.name": "latest" - } - } - ] -} diff --git a/oci/layout/fixtures/delete_image_sharedblobs/oci-layout b/oci/layout/fixtures/delete_image_sharedblobs/oci-layout deleted file mode 100644 index 21b1439d1c..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobs/oci-layout +++ /dev/null @@ -1 +0,0 @@ -{"imageLayoutVersion": "1.0.0"} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_sharedblobsdir/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 b/oci/layout/fixtures/delete_image_sharedblobsdir/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 deleted file mode 100644 index f0f06201be..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobsdir/blobs/sha256/a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423 +++ /dev/null @@ -1,30 +0,0 @@ -{ - "created": "2019-08-20T20:19:55.211423266Z", - "architecture": "amd64", - "os": "linux", - "config": { - "Env": [ - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - ], - "Cmd": [ - "/bin/sh" - ] - }, - "rootfs": { - "type": "layers", - "diff_ids": [ - "sha256:03901b4a2ea88eeaad62dbe59b072b28b6efa00491962b8741081c5df50c65e0" - ] - }, - "history": [ - { - "created": "2019-08-20T20:19:55.062606894Z", - "created_by": "/bin/sh -c #(nop) ADD file:fe64057fbb83dccb960efabbf1cd8777920ef279a7fa8dbca0a8801c651bdf7c in / " - }, - { - "created": "2019-08-20T20:19:55.211423266Z", - "created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]", - "empty_layer": true - } - ] -} diff --git a/oci/layout/fixtures/delete_image_sharedblobsdir/oci-layout b/oci/layout/fixtures/delete_image_sharedblobsdir/oci-layout deleted file mode 100644 index 21b1439d1c..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobsdir/oci-layout +++ /dev/null @@ -1 +0,0 @@ -{"imageLayoutVersion": "1.0.0"} \ No newline at end of file diff --git a/oci/layout/fixtures/delete_image_sharedblobsdir/shared_blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc b/oci/layout/fixtures/delete_image_sharedblobsdir/shared_blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc deleted file mode 100644 index e7e64ba41b..0000000000 --- a/oci/layout/fixtures/delete_image_sharedblobsdir/shared_blobs/sha256/0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc +++ /dev/null @@ -1 +0,0 @@ -insert binary content here #9671 diff --git a/oci/layout/oci_delete.go b/oci/layout/oci_delete.go index c284c1719a..e4de6c204f 100644 --- a/oci/layout/oci_delete.go +++ b/oci/layout/oci_delete.go @@ -1,12 +1,11 @@ package layout import ( - "bytes" "context" "encoding/json" + "fmt" "io/fs" "os" - "path/filepath" "github.com/containers/image/v5/internal/set" "github.com/containers/image/v5/types" @@ -22,58 +21,145 @@ func (ref ociReference) DeleteImage(ctx context.Context, sys *types.SystemContex sharedBlobsDir = sys.OCISharedBlobDirPath } - // Scan all the manifests in the directory: - // ... collect the one that matches with the received ref - // ... and store all the blobs used in all other images - var imageDescriptorWrapper *descriptorWrapper - blobsUsedByOtherImages := set.New[digest.Digest]() - allDescriptors, err := ref.getAllImageDescriptorsInDirectory() + desciptor, err := ref.getManifestDescriptor() if err != nil { return err } - if ref.image == "" { - if len(allDescriptors) == 1 { - imageDescriptorWrapper = &allDescriptors[0] - } else { - return ErrMoreThanOneImage - } - } else { - for _, v := range allDescriptors { - if v.descriptor.Annotations[imgspecv1.AnnotationRefName] == ref.image { - tmpDescriptionWrapper := v - imageDescriptorWrapper = &tmpDescriptionWrapper - } else { - otherImageManifest, err := ref.getManifest(v.descriptor, sharedBlobsDir) - if err != nil { - return err - } - blobsUsedByOtherImages.Add(otherImageManifest.Config.Digest) - for _, layer := range otherImageManifest.Layers { - blobsUsedByOtherImages.Add(layer.Digest) - } + switch desciptor.MediaType { + case imgspecv1.MediaTypeImageManifest: + return ref.deleteSingleImage(&desciptor, sharedBlobsDir) + case imgspecv1.MediaTypeImageIndex: + return ref.deleteImageIndex(&desciptor, sharedBlobsDir) + default: + return fmt.Errorf("unsupported mediaType in index") + } +} + +func (ref ociReference) deleteSingleImage(desciptor *imgspecv1.Descriptor, sharedBlobsDir string) error { + manifest, err := ref.getManifest(desciptor, sharedBlobsDir) + if err != nil { + return err + } + blobsUsedInManifest := ref.getBlobsUsedInManifest(manifest) + blobsUsedInManifest[desciptor.Digest]++ // Add the current manifest to the list of blobs used by this reference + + blobsToDelete, err := ref.getBlobsToDelete(blobsUsedInManifest, sharedBlobsDir) + if err != nil { + return err + } + + err = ref.deleteBlobs(blobsToDelete) + if err != nil { + return err + } + + return ref.deleteReferenceFromIndex() +} + +func (ref ociReference) deleteImageIndex(desciptor *imgspecv1.Descriptor, sharedBlobsDir string) error { + blobPath, err := ref.blobPath(desciptor.Digest, sharedBlobsDir) + if err != nil { + return err + } + index, err := parseIndex(blobPath) + if err != nil { + return err + } + + blobsUsedInImageRefIndex, err := ref.getBlobsUsedInIndex(index, sharedBlobsDir) + if err != nil { + return err + } + blobsUsedInImageRefIndex[desciptor.Digest]++ // Add the nested index in the list of blobs used by this reference + + blobsToDelete, err := ref.getBlobsToDelete(blobsUsedInImageRefIndex, sharedBlobsDir) + if err != nil { + return err + } + + err = ref.deleteBlobs(blobsToDelete) + if err != nil { + return err + } + + return ref.deleteReferenceFromIndex() +} + +// Returns a map of digest with the usage count, so a blob that is referenced three times will have 3 in the map +func (ref ociReference) getBlobsUsedInIndex(index *imgspecv1.Index, sharedBlobsDir string) (map[digest.Digest]int, error) { + blobsUsedInIndex := make(map[digest.Digest]int) + + for _, desciptor := range index.Manifests { + blobsUsedInIndex[desciptor.Digest]++ + switch desciptor.MediaType { + case imgspecv1.MediaTypeImageManifest: + manifest, err := ref.getManifest(&desciptor, sharedBlobsDir) + if err != nil { + return nil, err + } + for digest, count := range ref.getBlobsUsedInManifest(manifest) { + blobsUsedInIndex[digest] += count + } + case imgspecv1.MediaTypeImageIndex: + blobPath, err := ref.blobPath(desciptor.Digest, sharedBlobsDir) + if err != nil { + return nil, err + } + index, err := parseIndex(blobPath) + if err != nil { + return nil, err + } + blobsUsedInNestedIndex, err := ref.getBlobsUsedInIndex(index, sharedBlobsDir) + if err != nil { + return nil, err } + for k, v := range blobsUsedInNestedIndex { + blobsUsedInIndex[k] = blobsUsedInIndex[k] + v + } + default: + return nil, fmt.Errorf("unsupported mediaType in index") } } - if ref.image != "" && imageDescriptorWrapper == nil { - return ImageNotFoundError{ref} + return blobsUsedInIndex, nil +} + +func (ref ociReference) getBlobsUsedInManifest(manifest *imgspecv1.Manifest) map[digest.Digest]int { + blobsUsedInManifest := make(map[digest.Digest]int, 0) + + blobsUsedInManifest[manifest.Config.Digest]++ + for _, layer := range manifest.Layers { + blobsUsedInManifest[layer.Digest]++ } - manifest, err := ref.getManifest(imageDescriptorWrapper.descriptor, sharedBlobsDir) + return blobsUsedInManifest +} + +// This takes in a map of the digest and their usage count in the manifest to be deleted +// It will compare it to the digest usage in the root index, and return a set of the blobs that can be safely deleted +func (ref ociReference) getBlobsToDelete(blobsUsedByDescriptorToDelete map[digest.Digest]int, sharedBlobsDir string) (*set.Set[digest.Digest], error) { + rootIndex, err := ref.getIndex() if err != nil { - return err + return nil, err + } + blobsUsedInRootIndex, err := ref.getBlobsUsedInIndex(rootIndex, sharedBlobsDir) + if err != nil { + return nil, err } - // Delete all blobs used by this image only blobsToDelete := set.New[digest.Digest]() - for _, descriptor := range append(manifest.Layers, manifest.Config, *imageDescriptorWrapper.descriptor) { - if !blobsUsedByOtherImages.Contains(descriptor.Digest) { - blobsToDelete.Add(descriptor.Digest) - } else { - logrus.Debug("Blob ", descriptor.Digest.Hex(), " is used by another image, leaving it") + + for digest, count := range blobsUsedInRootIndex { + if count-blobsUsedByDescriptorToDelete[digest] == 0 { + blobsToDelete.Add(digest) } } + + return blobsToDelete, nil +} + +func (ref ociReference) deleteBlobs(blobsToDelete *set.Set[digest.Digest]) error { for _, digest := range blobsToDelete.Values() { blobPath, err := ref.blobPath(digest, "") //Only delete in the local directory, not in the shared blobs path if err != nil { @@ -86,7 +172,6 @@ func (ref ociReference) DeleteImage(ctx context.Context, sys *types.SystemContex if err != nil && !os.IsNotExist(err) { return err } - // } else { if os.IsNotExist(err) { logrus.Info("Blob ", digest.Hex(), " not found in image directory; it was either previously deleted or is in the shared blobs directory") @@ -96,76 +181,29 @@ func (ref ociReference) DeleteImage(ctx context.Context, sys *types.SystemContex } } - // This holds the step to be done on the current index, as we walk back bottom up - step := indexUpdateStep{"delete", imageDescriptorWrapper.descriptor.Digest, nil} + return nil +} - for i := len(imageDescriptorWrapper.indexChain) - 1; i >= 0; i-- { - indexPath := imageDescriptorWrapper.indexChain[i] - index, err := parseIndex(indexPath) - if err != nil { - return err - } - // Fill new index with existing manifests except the one we are removing - newManifests := make([]imgspecv1.Descriptor, 0, len(index.Manifests)) - for _, v := range index.Manifests { - if v.Digest == step.digest { - switch step.action { - case "delete": - continue - case "update": - newDescriptor := v - newDescriptor.Digest = *step.newDigest - newManifests = append(newManifests, newDescriptor) - } - } else { - newManifests = append(newManifests, v) - } - } - index.Manifests = newManifests +func (ref ociReference) deleteReferenceFromIndex() error { + index, err := ref.getIndex() + if err != nil { + return err + } - // New index is ready, it has to be saved to disk now - // ... if it is the root index, it's easy, just overwrite it - if indexPath == ref.indexPath() { - return saveJSON(ref.indexPath(), index) - } else { - indexDigest, err := digest.Parse("sha256:" + filepath.Base(indexPath)) - if err != nil { - return err - } - // In a nested index, if the new index is empty it has to be remove, - // otherwise update the parent index with the new hash - if len(index.Manifests) == 0 { - step = indexUpdateStep{"delete", indexDigest, nil} - } else { - // Save the new file - buffer := new(bytes.Buffer) - err = json.NewEncoder(buffer).Encode(index) - if err != nil { - return err - } - indexNewDigest := digest.Canonical.FromBytes(buffer.Bytes()) - indexNewPath, err := ref.blobPath(indexNewDigest, sharedBlobsDir) - if err != nil { - return err - } - err = saveJSON(indexNewPath, index) - if err != nil { - return err - } - step = indexUpdateStep{"update", indexDigest, &indexNewDigest} - } - // Delete the current index if it is not reference anywhere else; - // it is dangling by now as it'll either be empty or have a new hash - if !blobsUsedByOtherImages.Contains(indexDigest) { - err = os.Remove(indexPath) - if err != nil { - return err - } - } + if ref.image == "" && len(index.Manifests) == 1 { + index.Manifests = make([]imgspecv1.Descriptor, 0) + return saveJSON(ref.indexPath(), index) + } + + newDescriptors := make([]imgspecv1.Descriptor, 0, len(index.Manifests)-1) + for _, descriptor := range index.Manifests { + if descriptor.Annotations[imgspecv1.AnnotationRefName] != ref.image { + newDescriptors = append(newDescriptors, descriptor) } } + index.Manifests = newDescriptors - return nil + return saveJSON(ref.indexPath(), index) } func saveJSON(path string, content any) error { @@ -182,7 +220,6 @@ func saveJSON(path string, content any) error { mode = existingfi.Mode() } - // Then write the file file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, mode) if err != nil { return err @@ -192,50 +229,6 @@ func saveJSON(path string, content any) error { return json.NewEncoder(file).Encode(content) } -// Stores an (image) descriptor along with the index it was found in and its parents if any -// this allows the update of the index when an image is located in a nested (++) index -type descriptorWrapper struct { - descriptor *imgspecv1.Descriptor - indexChain []string //in order of appearence, the first is always be index.json and the nested indexes, last one being the one where the descriptor was found in -} - -// This will return all the descriptors of all the images found in the directory -// It starts at the index.json and then walks all nested indexes -// Each image descriptor is returned along with the index it was found, as well as it parents if it is a nested index -func (ref ociReference) getAllImageDescriptorsInDirectory() ([]descriptorWrapper, error) { - descriptors := make([]descriptorWrapper, 0) - var getImageDescriptorsFromIndex func(indexChain []string) error - getImageDescriptorsFromIndex = func(indexChain []string) error { - index, err := parseIndex(indexChain[len(indexChain)-1]) // last item in the index is always the index in which whe are currently working - if err != nil { - return err - } - - for _, manifestDescriptor := range index.Manifests { - switch manifestDescriptor.MediaType { - case imgspecv1.MediaTypeImageManifest: - tmpManifestDescriptor := manifestDescriptor - wrapper := descriptorWrapper{&tmpManifestDescriptor, indexChain} - descriptors = append(descriptors, wrapper) - case imgspecv1.MediaTypeImageIndex: - nestedIndexBlobPath, err := ref.blobPath(manifestDescriptor.Digest, "") // Only scan the local directory, not the shared blobs directory - if err != nil { - return err - } - // recursively get manifests from this nested index - err = getImageDescriptorsFromIndex(append(indexChain, nestedIndexBlobPath)) - if err != nil { - return err - } - } - } - return nil - } - - err := getImageDescriptorsFromIndex([]string{ref.indexPath()}) //Start the walk at the root (index.json) - return descriptors, err -} - func (ref ociReference) getManifest(descriptor *imgspecv1.Descriptor, sharedBlobsDir string) (*imgspecv1.Manifest, error) { manifestPath, err := ref.blobPath(descriptor.Digest, sharedBlobsDir) if err != nil { @@ -249,9 +242,3 @@ func (ref ociReference) getManifest(descriptor *imgspecv1.Descriptor, sharedBlob return manifest, nil } - -type indexUpdateStep struct { - action string - digest digest.Digest - newDigest *digest.Digest -} diff --git a/oci/layout/oci_delete_test.go b/oci/layout/oci_delete_test.go index 4e37efdb58..c5dd9c770a 100644 --- a/oci/layout/oci_delete_test.go +++ b/oci/layout/oci_delete_test.go @@ -14,8 +14,8 @@ import ( "github.com/stretchr/testify/require" ) -func TestReferenceDeleteImage(t *testing.T) { - tmpDir := loadFixture(t, "delete_image") +func TestReferenceDeleteImage_onlyOneImage(t *testing.T) { + tmpDir := loadFixture(t, "delete_image_only_one_image") ref, err := NewReference(tmpDir, "latest") require.NoError(t, err) @@ -37,8 +37,31 @@ func TestReferenceDeleteImage(t *testing.T) { require.Equal(t, 0, len(index.Manifests)) } +func TestReferenceDeleteImage_onlyOneImage_emptyImageName(t *testing.T) { + tmpDir := loadFixture(t, "delete_image_only_one_image") + + ref, err := NewReference(tmpDir, "") + require.NoError(t, err) + + err = ref.DeleteImage(context.Background(), nil) + require.NoError(t, err) + + // Check that all blobs were deleted + blobsDir := filepath.Join(tmpDir, "blobs") + files, err := os.ReadDir(filepath.Join(blobsDir, "sha256")) + require.NoError(t, err) + require.Empty(t, files) + + // Check that the index is empty as there is only one image in the fixture + ociRef, ok := ref.(ociReference) + require.True(t, ok) + index, err := ociRef.getIndex() + require.NoError(t, err) + require.Equal(t, 0, len(index.Manifests)) +} + func TestReferenceDeleteImage_sharedBlobDir(t *testing.T) { - tmpDir := loadFixture(t, "delete_image_sharedblobsdir") + tmpDir := loadFixture(t, "delete_image_shared_blobs_dir") ref, err := NewReference(tmpDir, "latest") require.NoError(t, err) @@ -67,43 +90,46 @@ func TestReferenceDeleteImage_sharedBlobDir(t *testing.T) { require.Equal(t, 0, len(index.Manifests)) } -func TestReferenceDeleteImage_emptyImageName(t *testing.T) { - tmpDir := loadFixture(t, "delete_image") +func TestReferenceDeleteImage_multipleImages(t *testing.T) { + tmpDir := loadFixture(t, "delete_image_multiple_images") - ref, err := NewReference(tmpDir, "") + ref, err := NewReference(tmpDir, "3.17.5") require.NoError(t, err) err = ref.DeleteImage(context.Background(), nil) require.NoError(t, err) - // Check that all blobs were deleted + // Check that the relevant blobs were deleted/preservend blobsDir := filepath.Join(tmpDir, "blobs") files, err := os.ReadDir(filepath.Join(blobsDir, "sha256")) require.NoError(t, err) - require.Empty(t, files) + require.Equal(t, 16, len(files)) + blobDoesNotExist(t, blobsDir, "sha256:5b2aba4d3c27bc6493633d0ec446b25c8d0a5c9cfe99894bcdff0aee80813805") + blobDoesNotExist(t, blobsDir, "sha256:df11bc189adeb50dadb3291a3a7f2c34b36e0efdba0df70f2c8a2d761b215cde") + blobDoesNotExist(t, blobsDir, "sha256:986315a0e599fac2b80eb31db2124dab8d3de04d7ca98b254999bd913c1f73fe") - // Check that the index is empty as there is only one image in the fixture + // Check the index ociRef, ok := ref.(ociReference) require.True(t, ok) + // .. Check that the index has been reduced to the correct size index, err := ociRef.getIndex() require.NoError(t, err) - require.Equal(t, 0, len(index.Manifests)) -} - -func TestReferenceDeleteImage_imageDoesNotExist(t *testing.T) { - tmpDir := loadFixture(t, "delete_image") - - ref, err := NewReference(tmpDir, "does-not-exist") - assert.NoError(t, err) - - err = ref.DeleteImage(context.Background(), nil) - assert.Error(t, err) + require.Equal(t, 6, len(index.Manifests)) + // .. Check that the image is not in the index anymore + for _, descriptor := range index.Manifests { + switch descriptor.Annotations[imgspecv1.AnnotationRefName] { + case "3.17.5": + assert.Fail(t, "image still present in the index after deletion") + default: + continue + } + } } -func TestReferenceDeleteImage_moreThanOneImageInIndex(t *testing.T) { - tmpDir := loadFixture(t, "delete_image_multipleimages") +func TestReferenceDeleteImage_multipleImages_blobsUsedByOtherImages(t *testing.T) { + tmpDir := loadFixture(t, "delete_image_multiple_images") - ref, err := NewReference(tmpDir, "3.2") + ref, err := NewReference(tmpDir, "1.0.0") require.NoError(t, err) err = ref.DeleteImage(context.Background(), nil) @@ -111,32 +137,43 @@ func TestReferenceDeleteImage_moreThanOneImageInIndex(t *testing.T) { // Check that the relevant blobs were deleted/preservend blobsDir := filepath.Join(tmpDir, "blobs") - blobDoesNotExist(t, blobsDir, "sha256:9a48d58d496b700f364686fbfbb2141ff5f0f25b033078a4c11fe597770b6fab") // menifest of the deleted image - blobDoesNotExist(t, blobsDir, "sha256:8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e") // config of the deleted image - blobDoesNotExist(t, blobsDir, "sha256:d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545") // layer of the deleted image - blobExists(t, blobsDir, "sha256:f082a2f88d9405f9d583e5038c76290d10dbefdb9b2137301c1e867f6f43cff6") // manifest of the other image present in the index - blobExists(t, blobsDir, "sha256:a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423") // config of the other image present in the index - blobExists(t, blobsDir, "sha256:bc584603ae5ca55d701f5134a0e5699056536885580ee929945bcbfeaf2633e6") // layer of the other image present in the index - - // Check that the index doesn't contain the reference anymore + files, err := os.ReadDir(filepath.Join(blobsDir, "sha256")) + require.NoError(t, err) + require.Equal(t, 17, len(files)) + blobExists(t, blobsDir, "sha256:df11bc189adeb50dadb3291a3a7f2c34b36e0efdba0df70f2c8a2d761b215cde") + blobDoesNotExist(t, blobsDir, "sha256:0dc27f36a618c110ae851662c13283e9fbc1b5a5de003befc4bcefa5a05d2eef") + blobDoesNotExist(t, blobsDir, "sha256:a6f737ac2b84bc463f2ff721af39588c69646c82f79f3808236178e02e35b922") + + // Check the index ociRef, ok := ref.(ociReference) require.True(t, ok) - descriptors, err := ociRef.getAllImageDescriptorsInDirectory() + // .. Check that the index has been reduced to the correct size + index, err := ociRef.getIndex() require.NoError(t, err) - otherImageStillPresent := false //This will track that other images are still there - for _, v := range descriptors { - switch v.descriptor.Annotations[imgspecv1.AnnotationRefName] { - case ociRef.image: + require.Equal(t, 6, len(index.Manifests)) + // .. Check that the image is not in the index anymore + for _, descriptor := range index.Manifests { + switch descriptor.Annotations[imgspecv1.AnnotationRefName] { + case "1.0.0": assert.Fail(t, "image still present in the index after deletion") - case "3.10.2": - otherImageStillPresent = true + default: + continue } } - require.True(t, otherImageStillPresent) } -func TestReferenceDeleteImage_emptyImageNameButMoreThanOneImageInIndex(t *testing.T) { - tmpDir := loadFixture(t, "delete_image_multipleimages") +func TestReferenceDeleteImage_multipleImages_imageDoesNotExist(t *testing.T) { + tmpDir := loadFixture(t, "delete_image_multiple_images") + + ref, err := NewReference(tmpDir, "does-not-exist") + assert.NoError(t, err) + + err = ref.DeleteImage(context.Background(), nil) + assert.Error(t, err) +} + +func TestReferenceDeleteImage_multipleImages_emptyImageName(t *testing.T) { + tmpDir := loadFixture(t, "delete_image_multiple_images") ref, err := NewReference(tmpDir, "") require.NoError(t, err) @@ -145,68 +182,68 @@ func TestReferenceDeleteImage_emptyImageNameButMoreThanOneImageInIndex(t *testin require.Error(t, err) } -func TestReferenceDeleteImage_someBlobsAreUsedByOtherImages(t *testing.T) { - tmpDir := loadFixture(t, "delete_image_sharedblobs") +func TestReferenceDeleteImage_multipleImages_nestedIndexImage(t *testing.T) { + tmpDir := loadFixture(t, "delete_image_multiple_images") - ref, err := NewReference(tmpDir, "3.2") + ref, err := NewReference(tmpDir, "3.16.7") require.NoError(t, err) err = ref.DeleteImage(context.Background(), nil) require.NoError(t, err) - // Check that the relevant blobs were deleted/preserved + // Check that the relevant blobs were deleted/preservend blobsDir := filepath.Join(tmpDir, "blobs") - blobDoesNotExist(t, blobsDir, "sha256:2363edaccd5115dad0462eac535496a0b7b661311d1fb8ed7a1f51368bfa9f3a") // manifest for the image - blobExists(t, blobsDir, "sha256:8f891520c22dc085f86a1a9aef2e1165e63e7465ae2112df6bd1d7a115a12f8e") // configuration, used by another image too - blobExists(t, blobsDir, "sha256:d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545") // layer, used by another image too - blobDoesNotExist(t, blobsDir, "sha256:49b6418afb4ee08ba3956e4c344034c89a39ef1a451a55b44926ad9ee77e036b") // layer used by that image only + files, err := os.ReadDir(filepath.Join(blobsDir, "sha256")) + require.NoError(t, err) + require.Equal(t, 12, len(files)) + blobDoesNotExist(t, blobsDir, "sha256:861d3c014b0e3edcf80e6221247d6b2921a4f892feb9bafe9515b9975b78c44f") + blobDoesNotExist(t, blobsDir, "sha256:39c524417bb4228f9fcb0aef43a680b5fd6b9f3a1df2fd50509d047e47dad8be") + blobDoesNotExist(t, blobsDir, "sha256:f732172ad8d2a666550fa3ec37a5153d59acc95744562ae64cf62ded46de101a") + blobDoesNotExist(t, blobsDir, "sha256:02ea786cb1ff44d997661886a4186cbd8a1dc466938712bf7281379209476022") + blobDoesNotExist(t, blobsDir, "sha256:be6036f9b6a4e120a04868c47f1b8674f58b2fe5e410cba9f585a13ca8946cf0") + blobDoesNotExist(t, blobsDir, "sha256:7ffdfe7d276286b39a203dcc247949cf47c91d2d5e10a53a675c0962ed9e4402") + blobDoesNotExist(t, blobsDir, "sha256:e2f7e0374fd6a03d9c373f4d9a0c7802045cc3ddcc1433e89d83b81fa7007242") - // Check that the index doesn't contain the reference anymore + // Check the index ociRef, ok := ref.(ociReference) require.True(t, ok) - descriptors, err := ociRef.getAllImageDescriptorsInDirectory() + // .. Check that the index has been reduced to the correct size + index, err := ociRef.getIndex() require.NoError(t, err) - otherImagesStillPresent := make([]bool, 0, 2) //This will track that other images are still there - for _, v := range descriptors { - switch v.descriptor.Annotations[imgspecv1.AnnotationRefName] { - case ociRef.image: + require.Equal(t, 6, len(index.Manifests)) + // .. Check that the image is not in the index anymore + for _, descriptor := range index.Manifests { + switch descriptor.Annotations[imgspecv1.AnnotationRefName] { + case "3.16.7": assert.Fail(t, "image still present in the index after deletion") - case "3.10.2": - otherImagesStillPresent = append(otherImagesStillPresent, true) - case "latest": - otherImagesStillPresent = append(otherImagesStillPresent, true) + default: + continue } } - assert.Equal(t, []bool{true, true}, otherImagesStillPresent) } -func TestReferenceDeleteImage_inNestedIndex(t *testing.T) { - tmpDir := loadFixture(t, "delete_image_nestedindex") +func TestReferenceDeleteImage_multipleImages_nestedIndexImage_refWithSameContent(t *testing.T) { + tmpDir := loadFixture(t, "delete_image_multiple_images") - ref, err := NewReference(tmpDir, "latest") + ref, err := NewReference(tmpDir, "3.18.3") require.NoError(t, err) err = ref.DeleteImage(context.Background(), nil) require.NoError(t, err) - // Check that all relevant blobs were deleted/preserved + // Check that the relevant blobs were deleted/preservend blobsDir := filepath.Join(tmpDir, "blobs") - blobDoesNotExist(t, blobsDir, "sha256:4a6da698b869046086d0e6ba846f8b931cb33bbaa5c68025b4fd55f67a4f0513") // manifest for the image - blobDoesNotExist(t, blobsDir, "sha256:a527179158cd5cebc11c152b8637b47ce96c838ba2aa0de66d14f45cedc11423") // configuration for the image - blobDoesNotExist(t, blobsDir, "sha256:0c8b263642b51b5c1dc40fe402ae2e97119c6007b6e52146419985ec1f0092dc") // layer used by that image only - blobExists(t, blobsDir, "sha256:d107df792639f1ee2fc4555597cb0eec8978b07e45a68f782965fd00a8964545") // layer used by another image in the index(es) - - // Check that a few new blobs have been created after index deletion/update - blobDoesNotExist(t, blobsDir, "sha256:fbe294d1b627d6ee3c119d558dad8b1c4542cbc51c49ec45dd638921bc5921d0") // nested index 2 that contained the image and only that image - blobDoesNotExist(t, blobsDir, "sha256:b2ff1c27b718b90910711aeda5e02ebbf4440659edd589cc458b3039ea91b35f") // nested index 1, should have been renamed - see next line - blobExists(t, blobsDir, "sha256:13e9f5dde0af5d4303ef0e69d847bc14db6c86a7df616831e126821daf532982") // new sha of the nested index + files, err := os.ReadDir(filepath.Join(blobsDir, "sha256")) + require.NoError(t, err) + require.Equal(t, 19, len(files)) - // Check that the index has been update with the new nestedindex's sha + // Check the index ociRef, ok := ref.(ociReference) require.True(t, ok) + // .. Check that the index has been reduced to the correct size index, err := ociRef.getIndex() require.NoError(t, err) - assert.Equal(t, 1, len(index.Manifests)) + require.Equal(t, 6, len(index.Manifests)) } func loadFixture(t *testing.T, fixtureName string) string {