Class ContainerRegistryAuthSupplier
java.lang.Object
org.mandas.docker.client.auth.gcr.ContainerRegistryAuthSupplier
- All Implemented Interfaces:
RegistryAuthSupplier
A RegistryAuthSupplier for getting access tokens from a Google Cloud Platform service or user
account. This implementation uses the google-auth-library-oauth2-http library to get an access
token given an account's credentials, and will refresh the token if it expires within a
configurable amount of time.
To construct a new instance, use
fromStream(InputStream) to get a ContainerRegistryAuthSupplier.Builder if you
have credentials for the account to use, or you can use
forApplicationDefaultCredentials()
if you would like to use
the
Application Default Credentials.
The scopes used to fetch an access token and the minimum expiry time can be configured via the
Builder before calling ContainerRegistryAuthSupplier.Builder.build().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA Builder of ContainerRegistryAuthSupplier. -
Method Summary
Modifier and TypeMethodDescriptionReturns a RegistryAuth object that works with a given registry's API [e.g.Authentication info to pass in the X-Registry-Config header when building an image.Returns a RegistryAuth object that is valid for a Docker Swarm context [i.e.Constructs a ContainerRegistryAuthSupplier using the Application Default Credentials.forCredentials(com.google.auth.oauth2.GoogleCredentials credentials) Constructs a ContainerRegistryAuthSupplier using the specified credentials.fromStream(InputStream credentialsStream) Constructs a ContainerRegistryAuthSupplier for the account with the given credentials.
-
Method Details
-
fromStream
public static ContainerRegistryAuthSupplier.Builder fromStream(InputStream credentialsStream) throws IOException Constructs a ContainerRegistryAuthSupplier for the account with the given credentials.- Parameters:
credentialsStream- the credentials stream- Returns:
- a new
ContainerRegistryAuthSupplier.Builder - Throws:
IOException- when an error occured when reading from stream- See Also:
-
forApplicationDefaultCredentials
public static ContainerRegistryAuthSupplier.Builder forApplicationDefaultCredentials() throws IOExceptionConstructs a ContainerRegistryAuthSupplier using the Application Default Credentials.- Returns:
- a new
ContainerRegistryAuthSupplier.Builder - Throws:
IOException- when an error occured when reading from stream- See Also:
-
forCredentials
public static ContainerRegistryAuthSupplier.Builder forCredentials(com.google.auth.oauth2.GoogleCredentials credentials) Constructs a ContainerRegistryAuthSupplier using the specified credentials.- Parameters:
credentials- the google credentials- Returns:
- a new
ContainerRegistryAuthSupplier.Builder - See Also:
-
authFor
Description copied from interface:RegistryAuthSupplierReturns a RegistryAuth object that works with a given registry's API [e.g. GCR].- Specified by:
authForin interfaceRegistryAuthSupplier- Returns:
- the RegistryAuth to use when working with the image, or else
nullif no authentication info applies for this image - Throws:
DockerException
-
authForSwarm
Description copied from interface:RegistryAuthSupplierReturns 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:
authForSwarmin interfaceRegistryAuthSupplier- Returns:
- the RegistryAuth to use in Swarn, or else
nullfor no authentication info - Throws:
DockerException
-
authForBuild
Description copied from interface:RegistryAuthSupplierAuthentication info to pass in the X-Registry-Config header when building an image.- Specified by:
authForBuildin interfaceRegistryAuthSupplier- Returns:
- the registry configs
- Throws:
DockerException
-