Class RegistriesConf

java.lang.Object
land.oras.auth.RegistriesConf

@NullMarked public class RegistriesConf extends Object
Handle registries.conf configuration
  • Method Details

    • newConf

      public static RegistriesConf newConf(List<Path> configPaths)
      Create a new RegistriesConf instance by merging configuration from all provided paths that exist. Files are merged in list order: later entries override scalar values and augment collections.
      Parameters:
      configPaths - The ordered list of paths to load and merge.
      Returns:
      A new RegistriesConf instance.
    • newConf

      public static RegistriesConf newConf()
      Create a new RegistriesConf instance by loading configuration from standard paths. The user-local config (under $HOME) is tried first, then /etc/containers/registries.conf.
      Returns:
      A new RegistriesConf instance.
    • getUnqualifiedRegistries

      public List<String> getUnqualifiedRegistries()
      Get the list of unqualified registries.
      Returns:
      an unmodifiable list of unqualified registries.
    • getAliasKey

      public String getAliasKey(ContainerRef ref)
      Return the key of the alias
      Parameters:
      ref - the container reference to get the alias key for.
      Returns:
      the alias key for the given container reference, which is either the repository name
    • enforceShortNameMode

      public void enforceShortNameMode() throws OrasException
      Enforce the short name mode by checking the configuration. If the short name mode is set to ENFORCING or PERMISSIVE and there are multiple unqualified registries configured, this method throws an OrasException indicating that the configuration is invalid. If the configuration is valid, this method does nothing.
      Throws:
      OrasException - if the short name mode is set to ENFORCING or PERMISSIVE and there are multiple unqualified registries configured, indicating that the configuration is invalid.
    • getAliases

      public Map<String,String> getAliases()
      Return the aliases
      Returns:
      an unmodifiable map of aliases, where the key is the alias and the value is the actual registry URL.
    • hasAlias

      public boolean hasAlias(String alias)
      Check if the given alias exists in the configuration.
      Parameters:
      alias - the alias to check for existence.
      Returns:
      true if the alias exists, false otherwise.
    • isBlocked

      public boolean isBlocked(ContainerRef location)
      Check if the given registry is marked as blocked in the configuration.
      Parameters:
      location - the registry location to check for blocking.
      Returns:
      true if the registry is marked as blocked, false otherwise.
    • isInsecure

      public boolean isInsecure(Registry registry, ContainerRef location)
      Check if the given registry is marked as insecure in the configuration. If no entry found, we fall back to Registry configuration If the entry is found we use the insecure flag (or default true)
      Parameters:
      registry - The registry object
      location - the registry location to check for insecurity.
      Returns:
      true if the registry is marked as insecure, false otherwise.
    • rewrite

      public ContainerRef rewrite(ContainerRef ref)
      Rewrite the given container reference according to the matching registry configuration.
      Parameters:
      ref - the container reference to rewrite.
      Returns:
      the rewritten container reference.
    • getMirrors

      public List<RegistriesConf.MirrorConfig> getMirrors(ContainerRef ref)
      Return the ordered list of mirrors configured for the registry that matches the given reference.
      Parameters:
      ref - the container reference to look up mirrors for.
      Returns:
      an unmodifiable list of mirror configs (may be empty).
    • getApplicableMirrors

      public List<RegistriesConf.MirrorConfig> getApplicableMirrors(ContainerRef ref)
      Return the ordered list of mirrors that are applicable for the given reference, filtering out mirrors whose pull-from-mirror setting does not match the reference type (tag vs. digest). The registry-level mirror-by-digest-only flag, when true, overrides all per-mirror settings and restricts every mirror to digest-only pulls.
      Parameters:
      ref - the container reference to look up applicable mirrors for.
      Returns:
      an unmodifiable list of applicable mirror configs (may be empty).
    • rewriteForMirror

      public ContainerRef rewriteForMirror(ContainerRef ref, RegistriesConf.MirrorConfig mirror)
      Rewrite the given container reference to use the mirror's location, replacing the registry host.
      Parameters:
      ref - the original container reference.
      mirror - the mirror configuration to apply.
      Returns:
      the rewritten reference pointing at the mirror.