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();
}
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());
}
Aggregations