public class DockerCredentialHelper extends Object
The credential helpers are platform-specific ways of storing and retrieving registry auth information. Docker ships with OS-specific implementations, such as osxkeychain and wincred, as well as others. But they also allow third parties to implement their own credential helpers; for instance, Google (https://github.com/GoogleCloudPlatform/docker-credential-gcr) and Amazon (https://github.com/awslabs/amazon-ecr-credential-helper) have implementations for their cloud registries.
The main interface to this class is in four static methods, which perform the four
operations of a credential helper: get(String, String), list(String),
store(String, DockerCredentialHelperAuth), and erase(String, String).
They all take the name of the credential helper as an argument; this value is usually read
as the credsStore or a credsHelper from a docker config file (see DockerConfig).
The static methods all pass their operations down to a CredentialHelperDelegate
instance. By default this instance executes a command on the system. However, the delegate
is modifiable with setCredentialHelperDelegate(CredentialHelperDelegate) and
restoreSystemCredentialHelperDelegate() to facilitate testing.
| Constructor and Description |
|---|
DockerCredentialHelper() |
| Modifier and Type | Method and Description |
|---|---|
static int |
erase(String credsStore,
String registry)
Erase an auth value from a credsStore matching a registry.
|
static DockerCredentialHelperAuth |
get(String credsStore,
String registry)
Get an auth value from a credsStore for a registry.
|
static Map<String,String> |
list(String credsStore)
Lists credentials stored in the credsStore.
|
static int |
store(String credsStore,
DockerCredentialHelperAuth auth)
Store an auth value in the credsStore.
|
public static int store(String credsStore, DockerCredentialHelperAuth auth) throws IOException, InterruptedException
credsStore - Name of the docker credential helperauth - Auth object to storeIOException - When we cannot read from the credential helperInterruptedException - When writing to the credential helper
is interruptedpublic static int erase(String credsStore, String registry) throws IOException, InterruptedException
credsStore - Name of the docker credential helperregistry - The registry for which you want to erase the authIOException - When we cannot read from the credential helperInterruptedException - When writing to the credential helper
is interruptedpublic static DockerCredentialHelperAuth get(String credsStore, String registry) throws IOException
credsStore - Name of the docker credential helperregistry - The registry for which you want to authDockerCredentialHelperAuth auth objectIOException - When we cannot read from the credential helperpublic static Map<String,String> list(String credsStore) throws IOException
credsStore - Name of the docker credential helperIOException - When we cannot read from the credential helperCopyright © 2019. All rights reserved.