docs: public RegistryAuth authForRegistry(final Path configPath, final String registry)
        throws IOException {
      checkNotNull(configPath);
      checkNotNull(registry);
  
      final DockerConfig config = MAPPER.readValue(configPath.toFile(), DockerConfig.class);
      if (config == null) {
        return RegistryAuth.builder().build();
      }
  
      final RegistryAuth registryAuth = authForRegistry(config, registry);
      if (registryAuth != null) {
        return registryAuth;
      }
      // If the given server address didn't have a protocol try adding a protocol to the address.
      // This handles cases where older versions of Docker included the protocol when writing
      // auth tokens to config.json.
      try {
        final URI serverAddressUri = new URI(registry);
        if (serverAddressUri.getScheme() == null) {
          for (String proto : Arrays.asList("https://", "http://")) {
            final RegistryAuth protoRegistryAuth = authForRegistry(config, proto + registry);
            if (protoRegistryAuth != null) {
              return protoRegistryAuth;
            }
          }
        }
      } catch (URISyntaxException e) {
        // Nothing to do, just let this fall through below
      }
  
      throw new IllegalArgumentException(
          "registry \"" + registry + "\" does not appear in config file at " + configPath);
    }