Package com.google.cloud.tools.jib.api
Class RegistryImage
- java.lang.Object
-
- com.google.cloud.tools.jib.api.RegistryImage
-
public class RegistryImage extends java.lang.Object
Defines an image on a container registry that can be used as either a source or target image.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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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)
AddsCredentialRetriever
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.
-
-
-
Method Detail
-
named
public static RegistryImage named(ImageReference imageReference)
Instantiate with the image reference to use.- Parameters:
imageReference
- the image reference- Returns:
- a new
RegistryImage
-
named
public static RegistryImage named(java.lang.String imageReference) throws InvalidImageReferenceException
Instantiate with the image reference to use.- Parameters:
imageReference
- the image reference- Returns:
- a new
RegistryImage
- Throws:
InvalidImageReferenceException
- ifimageReference
is not a valid image reference
-
addCredential
public RegistryImage addCredential(java.lang.String username, java.lang.String password)
Adds a username-password credential to use to push/pull the image. This is a shorthand foraddCredentialRetriever(() -> Optional.of(Credential.basic(username, password)))
.- Parameters:
username
- the usernamepassword
- the password- Returns:
- this
-
addCredentialRetriever
public RegistryImage addCredentialRetriever(CredentialRetriever credentialRetriever)
AddsCredentialRetriever
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); } })
- Parameters:
credentialRetriever
- theCredentialRetriever
to add- Returns:
- this
-
-