From 9a7174ebdbd83ea282792abe364d75997462d1e1 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Mon, 15 Apr 2019 17:30:38 -0400 Subject: [PATCH 1/4] Reverse manifest V21 layers when adding --- .../tools/jib/image/json/JsonToImageTranslator.java | 4 +++- .../jib/image/json/JsonToImageTranslatorTest.java | 8 ++++++-- .../src/test/resources/core/json/v21manifest.json | 12 +++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/jib-core/src/main/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslator.java b/jib-core/src/main/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslator.java index ac1e8e193e..56b792d4c3 100644 --- a/jib-core/src/main/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslator.java +++ b/jib-core/src/main/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslator.java @@ -30,6 +30,7 @@ import com.google.cloud.tools.jib.image.ReferenceNoDiffIdLayer; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; import java.time.Duration; import java.time.Instant; import java.time.format.DateTimeParseException; @@ -72,7 +73,8 @@ public static Image toImage(V21ManifestTemplate manifestTemplate) throws LayerPropertyNotFoundException { Image.Builder imageBuilder = Image.builder(V21ManifestTemplate.class); - for (DescriptorDigest digest : manifestTemplate.getLayerDigests()) { + // V21 layers are in reverse order of V22. (The first layer is the latest one.) + for (DescriptorDigest digest : Lists.reverse(manifestTemplate.getLayerDigests())) { imageBuilder.addLayer(new DigestOnlyLayer(digest)); } diff --git a/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslatorTest.java b/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslatorTest.java index 7eea1d466e..1cd9465d63 100644 --- a/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslatorTest.java +++ b/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslatorTest.java @@ -59,11 +59,15 @@ public void testToImage_v21() Image image = JsonToImageTranslator.toImage(manifestTemplate); List layers = image.getLayers(); - Assert.assertEquals(1, layers.size()); + Assert.assertEquals(2, layers.size()); Assert.assertEquals( DescriptorDigest.fromDigest( - "sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad"), + "sha256:5bd451067f9ab05e97cda8476c82f86d9b69c2dffb60a8ad2fe3723942544ab3"), layers.get(0).getBlobDescriptor().getDigest()); + Assert.assertEquals( + DescriptorDigest.fromDigest( + "sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad"), + layers.get(1).getBlobDescriptor().getDigest()); } @Test diff --git a/jib-core/src/test/resources/core/json/v21manifest.json b/jib-core/src/test/resources/core/json/v21manifest.json index 4eaa389cf8..1eef70beb3 100644 --- a/jib-core/src/test/resources/core/json/v21manifest.json +++ b/jib-core/src/test/resources/core/json/v21manifest.json @@ -1 +1,11 @@ -{"schemaVersion":1,"fsLayers":[{"blobSum":"sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad"}],"history":[{"v1Compatibility":"some v1-compatible object"}]} \ No newline at end of file +{ + "schemaVersion":1, + "fsLayers": [ + {"blobSum":"sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad"}, + {"blobSum":"sha256:5bd451067f9ab05e97cda8476c82f86d9b69c2dffb60a8ad2fe3723942544ab3"} + ], + "history": [ + {"v1Compatibility":"some v1-compatible object"}, + {"v1Compatibility":"another v1-compatible object"} + ] +} From 089df8e816de71c878cbf033536e239961e364ac Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Mon, 15 Apr 2019 17:42:56 -0400 Subject: [PATCH 2/4] Update CHANGELOG --- jib-core/CHANGELOG.md | 2 ++ jib-gradle-plugin/CHANGELOG.md | 2 ++ jib-maven-plugin/CHANGELOG.md | 2 ++ 3 files changed, 6 insertions(+) diff --git a/jib-core/CHANGELOG.md b/jib-core/CHANGELOG.md index 6cf0b1c358..e459733e69 100644 --- a/jib-core/CHANGELOG.md +++ b/jib-core/CHANGELOG.md @@ -13,6 +13,8 @@ All notable changes to this project will be documented in this file. ### Fixed +- Bug adding base image layers in reverse order when registry uses V2 image manifest, schema version 2 ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) + ## 0.9.0 ### Added diff --git a/jib-gradle-plugin/CHANGELOG.md b/jib-gradle-plugin/CHANGELOG.md index 208621a401..983d1052ae 100644 --- a/jib-gradle-plugin/CHANGELOG.md +++ b/jib-gradle-plugin/CHANGELOG.md @@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file. ### Fixed +- Bug adding base image layers in reverse order when registry uses V2 image manifest, schema version 2 ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) + ## 1.1.0 ### Changed diff --git a/jib-maven-plugin/CHANGELOG.md b/jib-maven-plugin/CHANGELOG.md index a11bcfdeee..42b7986531 100644 --- a/jib-maven-plugin/CHANGELOG.md +++ b/jib-maven-plugin/CHANGELOG.md @@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file. ### Fixed +- Bug adding base image layers in reverse order when registry uses V2 image manifest, schema version 2 ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) + ## 1.1.0 ### Added From 0a5a906323d143cee86e9e7245b9527ac306dd90 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Mon, 15 Apr 2019 18:08:56 -0400 Subject: [PATCH 3/4] Fix wrong version in CHANGELOG --- jib-core/CHANGELOG.md | 2 +- jib-gradle-plugin/CHANGELOG.md | 2 +- jib-maven-plugin/CHANGELOG.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jib-core/CHANGELOG.md b/jib-core/CHANGELOG.md index e459733e69..091a0b6b40 100644 --- a/jib-core/CHANGELOG.md +++ b/jib-core/CHANGELOG.md @@ -13,7 +13,7 @@ All notable changes to this project will be documented in this file. ### Fixed -- Bug adding base image layers in reverse order when registry uses V2 image manifest, schema version 2 ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) +- Bug adding base image layers in reverse order and creating wrong image when registry uses V2 image manifest, schema version 1 such as Quay ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) ## 0.9.0 diff --git a/jib-gradle-plugin/CHANGELOG.md b/jib-gradle-plugin/CHANGELOG.md index 983d1052ae..5ccbabcdaf 100644 --- a/jib-gradle-plugin/CHANGELOG.md +++ b/jib-gradle-plugin/CHANGELOG.md @@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file. ### Fixed -- Bug adding base image layers in reverse order when registry uses V2 image manifest, schema version 2 ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) +- Bug adding base image layers in reverse order and creating wrong image when registry uses V2 image manifest, schema version 1 such as Quay ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) ## 1.1.0 diff --git a/jib-maven-plugin/CHANGELOG.md b/jib-maven-plugin/CHANGELOG.md index 42b7986531..72b7d07ad8 100644 --- a/jib-maven-plugin/CHANGELOG.md +++ b/jib-maven-plugin/CHANGELOG.md @@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file. ### Fixed -- Bug adding base image layers in reverse order when registry uses V2 image manifest, schema version 2 ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) +- Bug adding base image layers in reverse order and creating wrong image when registry uses V2 image manifest, schema version 1 such as Quay ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) ## 1.1.0 From 24c85a9872899dd6b23bf3ad877b5a830f2805dd Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 16 Apr 2019 11:06:35 -0400 Subject: [PATCH 4/4] Update CHANGELOG --- jib-core/CHANGELOG.md | 4 +++- jib-gradle-plugin/CHANGELOG.md | 4 +++- jib-maven-plugin/CHANGELOG.md | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/jib-core/CHANGELOG.md b/jib-core/CHANGELOG.md index 091a0b6b40..ad878877da 100644 --- a/jib-core/CHANGELOG.md +++ b/jib-core/CHANGELOG.md @@ -13,7 +13,7 @@ All notable changes to this project will be documented in this file. ### Fixed -- Bug adding base image layers in reverse order and creating wrong image when registry uses V2 image manifest, schema version 1 such as Quay ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) +- Fixed an issue where the library creates wrong images by adding base image layers in reverse order when registry uses the old V2 image manifest, schema version 1 (such as Quay) ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) ## 0.9.0 @@ -24,10 +24,12 @@ All notable changes to this project will be documented in this file. - Methods in `JavaContainerBuilder` for setting the destination directories for classes, resources, directories, and additional classpath files ### Changed + - Allow skipping `JavaContainerBuilder#setMainClass()` to skip setting the entrypoint - `os` and `architecture` are taken from base image ([#1564](https://github.com/GoogleContainerTools/jib/pull/1564)) ### Fixed + - `ImageReference` assumes `registry-1.docker.io` as the registry if the host part of an image reference is `docker.io` ([#1549](https://github.com/GoogleContainerTools/jib/issues/1549)) ## 0.1.2 diff --git a/jib-gradle-plugin/CHANGELOG.md b/jib-gradle-plugin/CHANGELOG.md index 5ccbabcdaf..b2f12a7484 100644 --- a/jib-gradle-plugin/CHANGELOG.md +++ b/jib-gradle-plugin/CHANGELOG.md @@ -9,14 +9,16 @@ All notable changes to this project will be documented in this file. ### Fixed -- Bug adding base image layers in reverse order and creating wrong image when registry uses V2 image manifest, schema version 1 such as Quay ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) +- Fixed an issue where the plugin creates wrong images by adding base image layers in reverse order when registry uses the old V2 image manifest, schema version 1 (such as Quay) ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) ## 1.1.0 ### Changed + - `os` and `architecture` are taken from base image ([#1564](https://github.com/GoogleContainerTools/jib/pull/1564)) ### Fixed + - Fixed an issue where pushing to Docker Hub fails when the host part of an image reference is `docker.io` ([#1549](https://github.com/GoogleContainerTools/jib/issues/1549)) ## 1.0.2 diff --git a/jib-maven-plugin/CHANGELOG.md b/jib-maven-plugin/CHANGELOG.md index 72b7d07ad8..a452b378fe 100644 --- a/jib-maven-plugin/CHANGELOG.md +++ b/jib-maven-plugin/CHANGELOG.md @@ -9,17 +9,20 @@ All notable changes to this project will be documented in this file. ### Fixed -- Bug adding base image layers in reverse order and creating wrong image when registry uses V2 image manifest, schema version 1 such as Quay ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) +- Fixed an issue where the plugin creates wrong images by adding base image layers in reverse order when registry uses the old V2 image manifest, schema version 1 (such as Quay) ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627)) ## 1.1.0 ### Added + - Can now decrypt proxy configurations in `settings.xml`. ([#1369](https://github.com/GoogleContainerTools/jib/issues/1369)) ### Changed + - `os` and `architecture` are taken from base image ([#1564](https://github.com/GoogleContainerTools/jib/pull/1564)) ### Fixed + - Fixed an issue where pushing to Docker Hub fails when the host part of an image reference is `docker.io` ([#1549](https://github.com/GoogleContainerTools/jib/issues/1549)) ## 1.0.2