Search in sources :

Example 11 with OciIndexTemplate

use of com.google.cloud.tools.jib.image.json.OciIndexTemplate in project jib by GoogleContainerTools.

the class CacheStorageReaderTest method testRetrieveMetadata_ociImageIndex.

@Test
public void testRetrieveMetadata_ociImageIndex() throws IOException, URISyntaxException, CacheCorruptedException {
    setupCachedMetadataOciImageIndex(cacheDirectory);
    ImageMetadataTemplate metadata = cacheStorageReader.retrieveMetadata(ImageReference.of("test", "image", "tag")).get();
    MatcherAssert.assertThat(metadata.getManifestList(), CoreMatchers.instanceOf(OciIndexTemplate.class));
    List<ContentDescriptorTemplate> manifestDescriptors = ((OciIndexTemplate) metadata.getManifestList()).getManifests();
    Assert.assertEquals(1, manifestDescriptors.size());
    Assert.assertEquals("8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad", manifestDescriptors.get(0).getDigest().getHash());
    Assert.assertEquals(1, metadata.getManifestsAndConfigs().size());
    ManifestAndConfigTemplate manifestAndConfig = metadata.getManifestsAndConfigs().get(0);
    OciManifestTemplate manifestTemplate = (OciManifestTemplate) manifestAndConfig.getManifest();
    Assert.assertEquals(2, manifestTemplate.getSchemaVersion());
    Assert.assertEquals("8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad", manifestTemplate.getContainerConfiguration().getDigest().getHash());
    Assert.assertEquals("wasm", manifestAndConfig.getConfig().getArchitecture());
}
Also used : OciManifestTemplate(com.google.cloud.tools.jib.image.json.OciManifestTemplate) ContentDescriptorTemplate(com.google.cloud.tools.jib.image.json.BuildableManifestTemplate.ContentDescriptorTemplate) OciIndexTemplate(com.google.cloud.tools.jib.image.json.OciIndexTemplate) ImageMetadataTemplate(com.google.cloud.tools.jib.image.json.ImageMetadataTemplate) ManifestAndConfigTemplate(com.google.cloud.tools.jib.image.json.ManifestAndConfigTemplate) Test(org.junit.Test)

Example 12 with OciIndexTemplate

use of com.google.cloud.tools.jib.image.json.OciIndexTemplate in project jib by GoogleContainerTools.

the class ManifestPullerTest method testHandleResponse_ociIndexWithNoMediaType.

@Test
public void testHandleResponse_ociIndexWithNoMediaType() throws IOException, UnknownManifestFormatException {
    String ociManifestJson = "{\n" + "  \"schemaVersion\": 2,\n" + "  \"manifests\": [\n" + "    {\n" + "      \"mediaType\": \"application/vnd.oci.image.manifest.v1+json\",\n" + "      \"size\": 7143,\n" + "      \"digest\": \"sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f\"\n" + "    }\n" + "  ]\n" + "}";
    Mockito.when(mockResponse.getBody()).thenReturn(stringToInputStreamUtf8(ociManifestJson));
    ManifestTemplate manifest = new ManifestPuller<>(fakeRegistryEndpointRequestProperties, "test-image-tag", ManifestTemplate.class).handleResponse(mockResponse).getManifest();
    MatcherAssert.assertThat(manifest, CoreMatchers.instanceOf(OciIndexTemplate.class));
    OciIndexTemplate ociIndex = (OciIndexTemplate) manifest;
    Assert.assertEquals("application/vnd.oci.image.index.v1+json", manifest.getManifestMediaType());
    Assert.assertEquals(1, ociIndex.getManifests().size());
    Assert.assertEquals("e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f", ociIndex.getManifests().get(0).getDigest().getHash());
}
Also used : OciIndexTemplate(com.google.cloud.tools.jib.image.json.OciIndexTemplate) V22ManifestTemplate(com.google.cloud.tools.jib.image.json.V22ManifestTemplate) V21ManifestTemplate(com.google.cloud.tools.jib.image.json.V21ManifestTemplate) OciManifestTemplate(com.google.cloud.tools.jib.image.json.OciManifestTemplate) ManifestTemplate(com.google.cloud.tools.jib.image.json.ManifestTemplate) Test(org.junit.Test)

Aggregations

OciIndexTemplate (com.google.cloud.tools.jib.image.json.OciIndexTemplate)12 OciManifestTemplate (com.google.cloud.tools.jib.image.json.OciManifestTemplate)12 Test (org.junit.Test)10 ImageMetadataTemplate (com.google.cloud.tools.jib.image.json.ImageMetadataTemplate)6 ManifestAndConfigTemplate (com.google.cloud.tools.jib.image.json.ManifestAndConfigTemplate)6 ContentDescriptorTemplate (com.google.cloud.tools.jib.image.json.BuildableManifestTemplate.ContentDescriptorTemplate)4 ContainerConfigurationTemplate (com.google.cloud.tools.jib.image.json.ContainerConfigurationTemplate)4 DescriptorDigest (com.google.cloud.tools.jib.api.DescriptorDigest)2 ImageReference (com.google.cloud.tools.jib.api.ImageReference)2 BlobDescriptor (com.google.cloud.tools.jib.blob.BlobDescriptor)2 BuildableManifestTemplate (com.google.cloud.tools.jib.image.json.BuildableManifestTemplate)2 ImageToJsonTranslator (com.google.cloud.tools.jib.image.json.ImageToJsonTranslator)2 ManifestTemplate (com.google.cloud.tools.jib.image.json.ManifestTemplate)2 V21ManifestTemplate (com.google.cloud.tools.jib.image.json.V21ManifestTemplate)2 V22ManifestTemplate (com.google.cloud.tools.jib.image.json.V22ManifestTemplate)2 JsonTemplate (com.google.cloud.tools.jib.json.JsonTemplate)2 TarStreamBuilder (com.google.cloud.tools.jib.tar.TarStreamBuilder)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStreamReader (java.io.InputStreamReader)2