Class RegistryAuthLocator
java.lang.Object
com.bmuschko.gradle.docker.internal.RegistryAuthLocator
Utility class to get credentials information from extension of type
DockerRegistryCredentials
or from $DOCKER_CONFIG/.docker/config.json
file.
Supports auth token, credentials store and credentials helpers. Only Linux OS is supported at the moment. Returns default auth object if called on Windows.
The class is ported from the testcontainers-java project (PR 729).
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetRegistry
(String image) Extract registry name from the image namecom.github.dockerjava.api.model.AuthConfigurations
Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an empty AuthConfigurations object is returnedcom.github.dockerjava.api.model.AuthConfigurations
lookupAllAuthConfigs
(DockerRegistryCredentials registryCredentials) Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an AuthConfigurations object containing only the passed registryCredentials is returnedcom.github.dockerjava.api.model.AuthConfigurations
lookupAllAuthConfigs
(com.github.dockerjava.api.model.AuthConfig additionalAuthConfig) Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an AuthConfigurations object containing only the passed additionalAuthConfig is returnedcom.github.dockerjava.api.model.AuthConfig
lookupAuthConfig
(String image, DockerRegistryCredentials registryCredentials) Gets authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, gets the information from the registryCredentials object
-
Method Details
-
lookupAuthConfig
public com.github.dockerjava.api.model.AuthConfig lookupAuthConfig(String image, DockerRegistryCredentials registryCredentials) Gets authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, gets the information from the registryCredentials object- Parameters:
registryCredentials
- extension of type registryCredentialsimage
- the name of docker image the action to be authorized for- Returns:
- AuthConfig object with a credentials info or default object if no credentials found
-
lookupAllAuthConfigs
public com.github.dockerjava.api.model.AuthConfigurations lookupAllAuthConfigs()Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an empty AuthConfigurations object is returned- Returns:
- AuthConfigurations object containing all authorization information, or an empty object if not available
-
lookupAllAuthConfigs
public com.github.dockerjava.api.model.AuthConfigurations lookupAllAuthConfigs(DockerRegistryCredentials registryCredentials) Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an AuthConfigurations object containing only the passed registryCredentials is returned- Parameters:
registryCredentials
- extension of type registryCredentials- Returns:
- AuthConfigurations object containing all authorization information (if available), and the registryCredentials
-
lookupAllAuthConfigs
public com.github.dockerjava.api.model.AuthConfigurations lookupAllAuthConfigs(com.github.dockerjava.api.model.AuthConfig additionalAuthConfig) Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an AuthConfigurations object containing only the passed additionalAuthConfig is returned- Parameters:
additionalAuthConfig
- An additional AuthConfig object to add to the discovered authorization information.- Returns:
- AuthConfigurations object containing all authorization information (if available), and the additionalAuthConfig
-
getRegistry
Extract registry name from the image name- Parameters:
image
- the name of the docker image- Returns:
- docker registry name
-