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 loading configuration from the specified paths.
      Parameters:
      configPaths - The list of paths to load configuration from.
      Returns:
      A new RegistriesConf instance.
    • newConf

      public static RegistriesConf newConf()
      Create a new RegistriesConf instance by loading configuration from standard paths.
      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(ContainerRef location)
      Check if the given registry is marked as insecure in the configuration.
      Parameters:
      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.