public CredentialRetriever wellKnownCredentialHelpers() {
    return () -> {
      for (Map.Entry<String, String> entry : WELL_KNOWN_CREDENTIAL_HELPERS.entrySet()) {
        try {
          String registrySuffix = entry.getKey();
          if (imageReference.getRegistry().endsWith(registrySuffix)) {
            String credentialHelper = entry.getValue();
            return Optional.of(retrieveFromDockerCredentialHelper(Paths.get(credentialHelper)));
          }

        } catch (CredentialHelperNotFoundException
            | CredentialHelperUnhandledServerUrlException ex) {
          if (ex.getMessage() != null) {
            // Warns the user that the specified (or inferred) credential helper cannot be used.
            logger.accept(LogEvent.info(ex.getMessage()));
            if (ex.getCause() != null && ex.getCause().getMessage() != null) {
              logger.accept(LogEvent.info("  Caused by: " + ex.getCause().getMessage()));
            }
          }

        } catch (IOException ex) {
          throw new CredentialRetrievalException(ex);
        }
      }
      return Optional.empty();
    };
  }
Creates a new {@link CredentialRetriever} that tries well-known Docker credential helpers to
retrieve credentials based on the registry of the image, such as {@code docker-credential-gcr}
for images with the registry ending with {@code gcr.io}.

@return a new {@link CredentialRetriever}
jib-core/src/main/java/com/google/cloud/tools/jib/frontend/CredentialRetrieverFactory.java