Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Reverse manifest V21 layers when adding #1633

Merged
merged 4 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jib-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,7 +73,8 @@ public static Image<Layer> toImage(V21ManifestTemplate manifestTemplate)
throws LayerPropertyNotFoundException {
Image.Builder<Layer> 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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ public void testToImage_v21()
Image<Layer> image = JsonToImageTranslator.toImage(manifestTemplate);

List<Layer> 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
Expand Down
12 changes: 11 additions & 1 deletion jib-core/src/test/resources/core/json/v21manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
{"schemaVersion":1,"fsLayers":[{"blobSum":"sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad"}],"history":[{"v1Compatibility":"some v1-compatible object"}]}
{
"schemaVersion":1,
"fsLayers": [
{"blobSum":"sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad"},
{"blobSum":"sha256:5bd451067f9ab05e97cda8476c82f86d9b69c2dffb60a8ad2fe3723942544ab3"}
],
"history": [
{"v1Compatibility":"some v1-compatible object"},
{"v1Compatibility":"another v1-compatible object"}
]
}
2 changes: 2 additions & 0 deletions jib-gradle-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 and creating wrong image when registry uses V2 image manifest, schema version 1 such as Quay ([#1627](https://github.com/GoogleContainerTools/jib/issues/1627))
chanseokoh marked this conversation as resolved.
Show resolved Hide resolved

## 1.1.0

### Changed
Expand Down
2 changes: 2 additions & 0 deletions jib-maven-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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

### Added
Expand Down