public ImageRegistry getImageRegistry(DockerConfig dockerConfig, String registry) {

        if (dockerConfig == null) {
            return null;
        }

        List<String> dockerRegistryAliases = null;
        if (registry != null) {
            dockerRegistryAliases = DockerHubAliases.getDockerRegistryAliases(registry);
        } else {
            dockerRegistryAliases = DockerHubAliases.getDefaultDockerRegistryAlias();
        }

        List<String> registryPatterns = new ArrayList<>();
        for (String registryAlias : dockerRegistryAliases) {
            registryPatterns.addAll(getRegistryPatterns(registryAlias));
        }
        for (String pattern : registryPatterns) {
            ImageRegistryBuilder builder = new ImageRegistryBuilder(pattern);
            DockerCredHelper dockerCredHelper = getDockerCredHelper(dockerConfig, pattern);
            ImageRegistry imageRegistry = dockerCredHelper != null ? builder.from(dockerCredHelper) : builder.from(dockerConfig.getAuths());
            if (imageRegistry != null) {
                return imageRegistry;
            }
        }
        return null;

    }
returns image registry credentials if found in docker config in the credHelpers,credsStore or Auths else returns null.

@param registry
@return ImageRegistry object if found in credHelpers,credsStore or Auths else returns null.
workflow-controller/controller-service/src/main/java/io/hyscale/controller/manager/impl/LocalRegistryManagerImpl.java