public class RegistryImage
extends java.lang.Object
The registry portion of the image reference determines which registry to the image lives (or
should live) on. The repository portion is the namespace within the registry. The tag is a label
to easily identify an image among all the images in the repository. See ImageReference
for more details.
When configuring credentials (via addCredential(java.lang.String, java.lang.String)
for example), make sure the
credentials are valid push (for using this as a target image) or pull (for using this as a source
image) credentials for the repository specified via the image reference.
Modifier and Type | Method and Description |
---|---|
RegistryImage |
addCredential(java.lang.String username,
java.lang.String password)
Adds a username-password credential to use to push/pull the image.
|
RegistryImage |
addCredentialRetriever(CredentialRetriever credentialRetriever)
Adds
CredentialRetriever to fetch push/pull credentials for the image. |
static RegistryImage |
named(ImageReference imageReference)
Instantiate with the image reference to use.
|
static RegistryImage |
named(java.lang.String imageReference)
Instantiate with the image reference to use.
|
public static RegistryImage named(ImageReference imageReference)
imageReference
- the image referenceRegistryImage
public static RegistryImage named(java.lang.String imageReference) throws InvalidImageReferenceException
imageReference
- the image referenceRegistryImage
InvalidImageReferenceException
- if imageReference
is not a valid image referencepublic RegistryImage addCredential(java.lang.String username, java.lang.String password)
addCredentialRetriever(() -> Optional.of(Credential.basic(username, password)))
.username
- the usernamepassword
- the passwordpublic RegistryImage addCredentialRetriever(CredentialRetriever credentialRetriever)
CredentialRetriever
to fetch push/pull credentials for the image. Credential
retrievers are attempted in the order in which they are specified until credentials are
successfully retrieved.
Example usage:
.addCredentialRetriever(() -> {
if (!Files.exists("secret.txt") {
return Optional.empty();
}
try {
String password = fetchPasswordFromFile("secret.txt");
return Credential.basic("myaccount", password);
} catch (IOException ex) {
throw new CredentialRetrievalException("Failed to load password", ex);
}
})
credentialRetriever
- the CredentialRetriever
to add