Search in sources :

Example 6 with CountingDigestOutputStream

use of com.google.cloud.tools.jib.hash.CountingDigestOutputStream in project jib by google.

the class BlobDescriptor method fromPipe.

/**
 * Creates a new {@link BlobDescriptor} from the contents of an {@link InputStream} while piping
 * to an {@link OutputStream}. Does not close either streams.
 */
static BlobDescriptor fromPipe(InputStream inputStream, OutputStream outputStream) throws IOException {
    CountingDigestOutputStream countingDigestOutputStream = new CountingDigestOutputStream(outputStream);
    ByteStreams.copy(inputStream, countingDigestOutputStream);
    countingDigestOutputStream.flush();
    return countingDigestOutputStream.toBlobDescriptor();
}
Also used : CountingDigestOutputStream(com.google.cloud.tools.jib.hash.CountingDigestOutputStream)

Example 7 with CountingDigestOutputStream

use of com.google.cloud.tools.jib.hash.CountingDigestOutputStream in project jib by google.

the class BlobPullerIntegrationTest method testPull.

@Test
public void testPull() throws IOException, RegistryException {
    // Pulls the busybox image.
    RegistryClient registryClient = new RegistryClient(null, "localhost:5000", "busybox");
    V21ManifestTemplate manifestTemplate = registryClient.pullManifest("latest", V21ManifestTemplate.class);
    DescriptorDigest realDigest = manifestTemplate.getLayerDigests().get(0);
    // Pulls a layer BLOB of the busybox image.
    CountingDigestOutputStream layerOutputStream = new CountingDigestOutputStream(ByteStreams.nullOutputStream());
    registryClient.pullBlob(realDigest, layerOutputStream);
    Assert.assertEquals(realDigest, layerOutputStream.toBlobDescriptor().getDigest());
}
Also used : CountingDigestOutputStream(com.google.cloud.tools.jib.hash.CountingDigestOutputStream) DescriptorDigest(com.google.cloud.tools.jib.image.DescriptorDigest) V21ManifestTemplate(com.google.cloud.tools.jib.image.json.V21ManifestTemplate) Test(org.junit.Test)

Aggregations

CountingDigestOutputStream (com.google.cloud.tools.jib.hash.CountingDigestOutputStream)7 DescriptorDigest (com.google.cloud.tools.jib.image.DescriptorDigest)4 BlobDescriptor (com.google.cloud.tools.jib.blob.BlobDescriptor)3 Blob (com.google.cloud.tools.jib.blob.Blob)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 GZIPOutputStream (java.util.zip.GZIPOutputStream)2 Timer (com.google.cloud.tools.jib.Timer)1 CachedLayer (com.google.cloud.tools.jib.cache.CachedLayer)1 Image (com.google.cloud.tools.jib.image.Image)1 UnwrittenLayer (com.google.cloud.tools.jib.image.UnwrittenLayer)1 ImageToJsonTranslator (com.google.cloud.tools.jib.image.json.ImageToJsonTranslator)1 V21ManifestTemplate (com.google.cloud.tools.jib.image.json.V21ManifestTemplate)1 RegistryClient (com.google.cloud.tools.jib.registry.RegistryClient)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 OutputStream (java.io.OutputStream)1 Path (java.nio.file.Path)1 Test (org.junit.Test)1