@Nullable
  DockerCredentialHelper getCredentialHelperFor(String registry) {
    List<Predicate<String>> registryMatchers = getRegistryMatchersFor(registry);

    Map.Entry<String, String> firstCredHelperMatch =
        findFirstInMapByKey(dockerConfigTemplate.getCredHelpers(), registryMatchers);
    if (firstCredHelperMatch != null) {
      return new DockerCredentialHelper(
          firstCredHelperMatch.getKey(),
          Paths.get("docker-credential-" + firstCredHelperMatch.getValue()));
    }

    if (dockerConfigTemplate.getCredsStore() != null) {
      return new DockerCredentialHelper(
          registry, Paths.get("docker-credential-" + dockerConfigTemplate.getCredsStore()));
    }

    return null;
  }
Determines a {@link DockerCredentialHelper} to use for {@code registry}.

<p>If there exists a matching registry entry (or its aliases) in {@code credHelpers}, returns
the corresponding credential helper. Otherwise, returns the credential helper defined by {@code
credStore}.

<p>See {@link #getRegistryMatchersFor} for the alias lookup order.

@param registry the registry to get the credential helpers for
@return the {@link DockerCredentialHelper} or {@code null} if none is found for the given
    registry
jib-core/src/main/java/com/google/cloud/tools/jib/registry/credentials/DockerConfig.java