public Blob toTarballBlob(ImageReference imageReference) throws IOException { TarStreamBuilder tarStreamBuilder = new TarStreamBuilder(); DockerLoadManifestEntryTemplate manifestTemplate = new DockerLoadManifestEntryTemplate(); // Adds all the layers to the tarball and manifest. for (Layer layer : image.getLayers()) { String layerName = layer.getBlobDescriptor().getDigest().getHash() + LAYER_FILE_EXTENSION; tarStreamBuilder.addBlobEntry( layer.getBlob(), layer.getBlobDescriptor().getSize(), layerName); manifestTemplate.addLayerFile(layerName); } // Adds the container configuration to the tarball. Blob containerConfigurationBlob = new ImageToJsonTranslator(image).getContainerConfigurationBlob(); tarStreamBuilder.addByteEntry( Blobs.writeToByteArray(containerConfigurationBlob), CONTAINER_CONFIGURATION_JSON_FILE_NAME); // Adds the manifest to tarball. manifestTemplate.setRepoTags(imageReference.toStringWithTag()); tarStreamBuilder.addByteEntry( Blobs.writeToByteArray( JsonTemplateMapper.toBlob(Collections.singletonList(manifestTemplate))), MANIFEST_JSON_FILE_NAME); return tarStreamBuilder.toBlob(); } }
public Blob toTarballBlob(ImageReference imageReference) throws IOException { TarStreamBuilder tarStreamBuilder = new TarStreamBuilder(); DockerLoadManifestEntryTemplate manifestTemplate = new DockerLoadManifestEntryTemplate(); // Adds all the layers to the tarball and manifest. for (Layer layer : image.getLayers()) { String layerName = layer.getBlobDescriptor().getDigest().getHash() + LAYER_FILE_EXTENSION; tarStreamBuilder.addBlobEntry( layer.getBlob(), layer.getBlobDescriptor().getSize(), layerName); manifestTemplate.addLayerFile(layerName); } // Adds the container configuration to the tarball. Blob containerConfigurationBlob = new ImageToJsonTranslator(image).getContainerConfigurationBlob(); tarStreamBuilder.addByteEntry( Blobs.writeToByteArray(containerConfigurationBlob), CONTAINER_CONFIGURATION_JSON_FILE_NAME); // Adds the manifest to tarball. manifestTemplate.setRepoTags(imageReference.toStringWithTag()); tarStreamBuilder.addByteEntry( Blobs.writeToByteArray( JsonTemplateMapper.toBlob(Collections.singletonList(manifestTemplate))), MANIFEST_JSON_FILE_NAME); return tarStreamBuilder.toBlob(); } }
public Blob toTarballBlob(ImageReference imageReference) throws IOException { TarStreamBuilder tarStreamBuilder = new TarStreamBuilder(); DockerLoadManifestEntryTemplate manifestTemplate = new DockerLoadManifestEntryTemplate(); // Adds all the layers to the tarball and manifest. for (Layer layer : image.getLayers()) { String layerName = layer.getBlobDescriptor().getDigest().getHash() + LAYER_FILE_EXTENSION; tarStreamBuilder.addBlobEntry( layer.getBlob(), layer.getBlobDescriptor().getSize(), layerName); manifestTemplate.addLayerFile(layerName); } // Adds the container configuration to the tarball. Blob containerConfigurationBlob = new ImageToJsonTranslator(image).getContainerConfigurationBlob(); tarStreamBuilder.addByteEntry( Blobs.writeToByteArray(containerConfigurationBlob), CONTAINER_CONFIGURATION_JSON_FILE_NAME); // Adds the manifest to tarball. manifestTemplate.setRepoTags(imageReference.toStringWithTag()); tarStreamBuilder.addByteEntry( Blobs.writeToByteArray( JsonTemplateMapper.toBlob(Collections.singletonList(manifestTemplate))), MANIFEST_JSON_FILE_NAME); return tarStreamBuilder.toBlob(); } }