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();
    };
  }
@Test
  public void testWellKnownCredentialHelpers() throws CredentialRetrievalException {
    CredentialRetrieverFactory credentialRetrieverFactory =
        createCredentialRetrieverFactory("something.gcr.io", "repo");

    Assert.assertEquals(
        Optional.of(FAKE_CREDENTIALS),
        credentialRetrieverFactory.wellKnownCredentialHelpers().retrieve());

    Mockito.verify(mockDockerCredentialHelperFactory)
        .create("something.gcr.io", Paths.get("docker-credential-gcr"), Collections.emptyMap());
    Mockito.verify(mockLogger)
        .accept(
            LogEvent.lifecycle(
                "Using credential helper docker-credential-gcr for something.gcr.io/repo"));
  }