Package land.oras

Class OCI<T extends Ref<@NonNull T>>

java.lang.Object
land.oras.OCI<T>
Type Parameters:
T - The reference type
Direct Known Subclasses:
OCILayout, Registry

public abstract sealed class OCI<T extends Ref<@NonNull T>> extends Object permits Registry, OCILayout
Abstract class for OCI operation on remote registry or layout Commons methods for OCI operations
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
      The logger
  • Constructor Details

    • OCI

      protected OCI()
      Default constructor
  • Method Details

    • pushArtifact

      public Manifest pushArtifact(T ref, LocalPath... paths)
      Push an artifact
      Parameters:
      ref - The ref
      paths - The paths
      Returns:
      The manifest
    • pushArtifact

      public Manifest pushArtifact(T ref, ArtifactType artifactType, LocalPath... paths)
      Push an artifact
      Parameters:
      ref - The ref
      artifactType - The artifact type
      paths - The paths
      Returns:
      The manifest
    • pushArtifact

      public Manifest pushArtifact(T ref, ArtifactType artifactType, Annotations annotations, LocalPath... paths)
      Upload an ORAS artifact
      Parameters:
      ref - The ref
      artifactType - The artifact type
      annotations - The annotations
      paths - The paths
      Returns:
      The manifest
    • pushBlob

      public Layer pushBlob(T ref, Path blob)
      Push a blob from file
      Parameters:
      ref - The ref
      blob - The blob
      Returns:
      The layer
    • pushBlob

      public Layer pushBlob(T ref, InputStream input)
      Push a blob from file
      Parameters:
      ref - The ref
      input - The input stream
      Returns:
      The layer
    • collectLayers

      protected List<Layer> collectLayers(T ref, String contentType, boolean includeAll)
      Collect layers from the ref
      Parameters:
      ref - The ref
      contentType - The content type
      includeAll - Include all layers or only the ones with title annotation
      Returns:
      The layers
    • pushLayers

      protected final List<Layer> pushLayers(T ref, boolean withDigest, LocalPath... paths)
      Push layers to the target
      Parameters:
      ref - The ref
      withDigest - Push with digest
      paths - The paths to the files
      Returns:
      The layers
    • isIndexMediaType

      protected boolean isIndexMediaType(String mediaType)
      Return if a media type is an index media type
      Parameters:
      mediaType - The media type
      Returns:
      True if it is a index media type
    • isManifestMediaType

      protected boolean isManifestMediaType(String mediaType)
      Return if a media type is a manifest media type
      Parameters:
      mediaType - The media type
      Returns:
      True if it is a manifest media type
    • pushConfig

      public final Config pushConfig(T ref, Config config)
      Push config
      Parameters:
      ref - The ref
      config - The config
      Returns:
      The config
    • pullConfig

      public final InputStream pullConfig(T ref, Config config)
      Pull config data or just return the data from config if set inline
      Parameters:
      ref - The ref
      config - The config
      Returns:
      The input stream
    • attachArtifact

      public final Manifest attachArtifact(T ref, ArtifactType artifactType, LocalPath... paths)
      Attach an artifact
      Parameters:
      ref - The ref
      artifactType - The artifact type
      paths - The paths
      Returns:
      The manifest
    • getTags

      public abstract Tags getTags(T ref)
      Get the tags for a ref
      Parameters:
      ref - The ref
      Returns:
      The tags
    • getRepositories

      public abstract Repositories getRepositories()
      Get the tags for a ref
      Returns:
      The repositories
    • pushArtifact

      public abstract Manifest pushArtifact(T ref, ArtifactType artifactType, Annotations annotations, @Nullable Config config, LocalPath... paths)
      Push an artifact
      Parameters:
      ref - The container
      artifactType - The artifact type. Can be null
      annotations - The annotations
      config - The config
      paths - The paths
      Returns:
      The manifest
    • pullArtifact

      public abstract void pullArtifact(T ref, Path path, boolean overwrite)
      Pull an artifact
      Parameters:
      ref - The reference of the artifact
      path - The path to save the artifact
      overwrite - Overwrite the artifact if it exists
    • pushManifest

      public abstract Manifest pushManifest(T ref, Manifest manifest)
      Push a manifest
      Parameters:
      ref - The ref
      manifest - The manifest
      Returns:
      The location
    • pushIndex

      public abstract Index pushIndex(T ref, Index index)
      Push an index
      Parameters:
      ref - The ref
      index - The index
      Returns:
      The index
    • getIndex

      public abstract Index getIndex(T ref)
      Retrieve an index
      Parameters:
      ref - The ref
      Returns:
      The index
    • getManifest

      public abstract Manifest getManifest(T ref)
      Retrieve a manifest
      Parameters:
      ref - The ref
      Returns:
      The manifest
    • getDescriptor

      public abstract Descriptor getDescriptor(T ref)
      Retrieve a descriptor
      Parameters:
      ref - The ref
      Returns:
      The descriptor
    • probeDescriptor

      public abstract Descriptor probeDescriptor(T ref)
      Probe a descriptor. Typically used to get digest, size and media type without the content
      Parameters:
      ref - The ref
      Returns:
      The descriptor
    • getBlob

      public abstract byte[] getBlob(T ref)
      Get the blob for the given digest. Not be suitable for large blobs
      Parameters:
      ref - The ref
      Returns:
      The blob as bytes
    • fetchBlob

      public abstract void fetchBlob(T ref, Path path)
      Fetch blob and save it to file
      Parameters:
      ref - The ref
      path - The path to save the blob
    • fetchBlob

      public abstract InputStream fetchBlob(T ref)
      Fetch blob and return it as input stream
      Parameters:
      ref - The ref
      Returns:
      The input stream
    • fetchBlobDescriptor

      public abstract Descriptor fetchBlobDescriptor(T ref)
      Fetch blob and return it's descriptor
      Parameters:
      ref - The ref
      Returns:
      The descriptor
    • pushBlob

      public abstract Layer pushBlob(T ref, Path blob, Map<String,String> annotations)
      Push a blob from file
      Parameters:
      ref - The container
      blob - The blob
      annotations - The annotations
      Returns:
      The layer
    • pushBlob

      public abstract Layer pushBlob(T ref, byte[] data)
      Push the blob for the given layer
      Parameters:
      ref - The container ref
      data - The data
      Returns:
      The layer
    • getReferrers

      public abstract Referrers getReferrers(T ref, @Nullable ArtifactType artifactType)
      Get the referrers of a container
      Parameters:
      ref - The ref
      artifactType - The optional artifact type
      Returns:
      The referrers
    • attachArtifact

      public Manifest attachArtifact(T ref, ArtifactType artifactType, Annotations annotations, LocalPath... paths)
      Attach file to an existing manifest
      Parameters:
      ref - The ref
      artifactType - The artifact type
      annotations - The annotations
      paths - The paths
      Returns:
      The manifest of the new artifact