Package land.oras.auth
Class RegistriesConf
java.lang.Object
land.oras.auth.RegistriesConf
Handle registries.conf configuration
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe model of a mirror entry within a [[registry]] table.static enumControls which pull operations may use a mirror. -
Method Summary
Modifier and TypeMethodDescriptionvoidEnforce the short name mode by checking the configuration.Return the aliasesgetAliasKey(ContainerRef ref) Return the key of the aliasReturn the ordered list of mirrors that are applicable for the given reference, filtering out mirrors whosepull-from-mirrorsetting does not match the reference type (tag vs. digest).getMirrors(ContainerRef ref) Return the ordered list of mirrors configured for the registry that matches the given reference.Get the list of unqualified registries.booleanCheck if the given alias exists in the configuration.booleanisBlocked(ContainerRef location) Check if the given registry is marked as blocked in the configuration.booleanisInsecure(Registry registry, ContainerRef location) Check if the given registry is marked as insecure in the configuration.static RegistriesConfnewConf()Create a new RegistriesConf instance by loading configuration from standard paths.static RegistriesConfCreate a new RegistriesConf instance by merging configuration from all provided paths that exist.rewrite(ContainerRef ref) Rewrite the given container reference according to the matching registry configuration.rewriteForMirror(ContainerRef ref, RegistriesConf.MirrorConfig mirror) Rewrite the given container reference to use the mirror's location, replacing the registry host.
-
Method Details
-
newConf
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
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
Get the list of unqualified registries.- Returns:
- an unmodifiable list of unqualified registries.
-
getAliasKey
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
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
Return the aliases- Returns:
- an unmodifiable map of aliases, where the key is the alias and the value is the actual registry URL.
-
hasAlias
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
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
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 objectlocation- the registry location to check for insecurity.- Returns:
- true if the registry is marked as insecure, false otherwise.
-
rewrite
Rewrite the given container reference according to the matching registry configuration.- Parameters:
ref- the container reference to rewrite.- Returns:
- the rewritten container reference.
-
getMirrors
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
Return the ordered list of mirrors that are applicable for the given reference, filtering out mirrors whosepull-from-mirrorsetting does not match the reference type (tag vs. digest). The registry-levelmirror-by-digest-onlyflag, 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
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.
-