@Override public DescriptorDigest getDiffId() throws LayerPropertyNotFoundException { throw new LayerPropertyNotFoundException( "Diff ID not available for reference layer without diff ID"); } }
/** * Returns {@code true} if the {@link ImageReference} uses the default tag ((@code latest} or * empty); {@code false} if not * * @return {@code true} if uses the default tag; {@code false} if not */ public boolean usesDefaultTag() { return isDefaultTag(tag); }
/** * Translates {@link V21ManifestTemplate} to {@link Image}. * * @param manifestTemplate the template containing the image layers. * @return the translated {@link Image}. * @throws LayerPropertyNotFoundException if adding image layers fails. */ public static Image<Layer> toImage(V21ManifestTemplate manifestTemplate) throws LayerPropertyNotFoundException { Image.Builder<Layer> imageBuilder = Image.builder(V21ManifestTemplate.class); for (DescriptorDigest digest : manifestTemplate.getLayerDigests()) { imageBuilder.addLayer(new DigestOnlyLayer(digest)); } return imageBuilder.build(); }
/** * Adds a layer to the image. * * @param layer the layer to add * @return this * @throws LayerPropertyNotFoundException if adding the layer fails */ public Builder<T> addLayer(T layer) throws LayerPropertyNotFoundException { imageLayersBuilder.add(layer); return this; }
@Override public int hashCode() { int result = digest.hashCode(); result = 31 * result + (int) (size ^ (size >>> 32)); return result; }
/** * Gets an {@link ImageReference} with the same registry and repository, but a different tag. * * @param newTag the new tag * @return an {@link ImageReference} with the same registry/repository and the new tag */ public ImageReference withTag(String newTag) { return ImageReference.of(registry, repository, newTag); }
/** * Stringifies the {@link ImageReference}, without hiding the tag. * * @return the image reference in Docker-readable format, without hiding the tag */ public String toStringWithTag() { return this + (usesDefaultTag() ? ":" + DEFAULT_TAG : ""); } }
/** * Gets the filename for the layer file. The filename is in the form {@code <layer diff * ID>.layer}. * * @param layerDiffId the layer's diff ID * @return the layer filename */ String getLayerFilename(DescriptorDigest layerDiffId) { return layerDiffId.getHash(); }
public static <T extends Layer> Builder<T> builder( Class<? extends ManifestTemplate> imageFormat) { return new Builder<>(imageFormat); }
public static <U extends Layer> Builder<U> builder() { return new Builder<>(); }
public String getImageRegistry() { return image.getRegistry(); }
public String getImageRepository() { return image.getRepository(); }
public String getImageTag() { return image.getTag(); }
@Override public Blob getBlob() throws LayerPropertyNotFoundException { throw new LayerPropertyNotFoundException( "Blob not available for reference layer without diff ID"); }
/** * Adds all layers in {@code layers}. * * @param <U> child type of {@link Layer} * @param layers the layers to add * @return this * @throws LayerPropertyNotFoundException if adding a layer fails */ public <U extends T> Builder<T> addAll(ImageLayers<U> layers) throws LayerPropertyNotFoundException { for (U layer : layers) { add(layer); } return this; }
@Override public Blob getBlob() throws LayerPropertyNotFoundException { throw new LayerPropertyNotFoundException("Blob not available for digest-only layer"); }
@Override public DescriptorDigest getDiffId() throws LayerPropertyNotFoundException { throw new LayerPropertyNotFoundException("Diff ID not available for digest-only layer"); } }
@Override public Blob getBlob() throws LayerPropertyNotFoundException { throw new LayerPropertyNotFoundException("Blob not available for reference layer"); }