Package com.spotify.docker.client.auth
Class ConfigFileRegistryAuthSupplier
- java.lang.Object
-
- com.spotify.docker.client.auth.ConfigFileRegistryAuthSupplier
-
- All Implemented Interfaces:
RegistryAuthSupplier
public class ConfigFileRegistryAuthSupplier extends java.lang.Object implements RegistryAuthSupplier
RegistryAuthSupplier that returns data from the docker-cli config file. The config file is re-read on each method call, to handle cases where a process is updating the file out-of-band during the lifecycle of a DockerClient instance.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.Logger
log
private java.nio.file.Path
path
private DockerConfigReader
reader
-
Constructor Summary
Constructors Constructor Description ConfigFileRegistryAuthSupplier()
ConfigFileRegistryAuthSupplier(DockerConfigReader reader)
ConfigFileRegistryAuthSupplier(DockerConfigReader reader, java.nio.file.Path path)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RegistryAuth
authFor(java.lang.String imageName)
Returns a RegistryAuth object that works with a given registry's API [e.g.RegistryConfigs
authForBuild()
Authentication info to pass in the X-Registry-Config header when building an image.RegistryAuth
authForSwarm()
Returns a RegistryAuth object that is valid for a Docker Swarm context [i.e.private boolean
configFileExists()
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
-
reader
private final DockerConfigReader reader
-
path
private final java.nio.file.Path path
-
-
Constructor Detail
-
ConfigFileRegistryAuthSupplier
public ConfigFileRegistryAuthSupplier()
-
ConfigFileRegistryAuthSupplier
public ConfigFileRegistryAuthSupplier(DockerConfigReader reader)
-
ConfigFileRegistryAuthSupplier
public ConfigFileRegistryAuthSupplier(DockerConfigReader reader, java.nio.file.Path path)
-
-
Method Detail
-
configFileExists
private boolean configFileExists()
-
authFor
public RegistryAuth authFor(java.lang.String imageName) throws DockerException
Description copied from interface:RegistryAuthSupplier
Returns a RegistryAuth object that works with a given registry's API [e.g. GCR].- Specified by:
authFor
in interfaceRegistryAuthSupplier
- Returns:
- the RegistryAuth to use when working with the image, or else
null
if no authentication info applies for this image - Throws:
DockerException
-
authForSwarm
public RegistryAuth authForSwarm() throws DockerException
Description copied from interface:RegistryAuthSupplier
Returns a RegistryAuth object that is valid for a Docker Swarm context [i.e. not tied to specific image]. It's unnecessary if it's not planned to use this AuthSupplier to pull images for Swarm.- Specified by:
authForSwarm
in interfaceRegistryAuthSupplier
- Returns:
- the RegistryAuth to use in Swarn, or else
null
for no authentication info - Throws:
DockerException
-
authForBuild
public RegistryConfigs authForBuild() throws DockerException
Description copied from interface:RegistryAuthSupplier
Authentication info to pass in the X-Registry-Config header when building an image.- Specified by:
authForBuild
in interfaceRegistryAuthSupplier
- Throws:
DockerException
-
-