Class 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 Detail

      • named

        public static RegistryImage named​(ImageReference imageReference)
        Instantiate with the image reference to use.
        Parameters:
        imageReference - the image reference
        Returns:
        a new RegistryImage
      • 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 for addCredentialRetriever(() -> Optional.of(Credential.basic(username, password))).
        Parameters:
        username - the username
        password - the password
        Returns:
        this
      • addCredentialRetriever

        public RegistryImage addCredentialRetriever​(CredentialRetriever credentialRetriever)
        Adds 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);
           }
         })
         
        Parameters:
        credentialRetriever - the CredentialRetriever to add
        Returns:
        this