From a64378ac59a30086d76f583dd3dc603ce05ec152 Mon Sep 17 00:00:00 2001 From: dubo-dubon-duponey Date: Tue, 1 Dec 2020 05:06:27 -0800 Subject: [PATCH] feat: adds support for OCI manifests (#316) Close #315 Signed-off-by: dubo-dubon-duponey --- docker/data_source_docker_registry_image.go | 8 ++++++-- docker/resource_docker_registry_image_funcs.go | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docker/data_source_docker_registry_image.go b/docker/data_source_docker_registry_image.go index 787a81bf..689f2a76 100644 --- a/docker/data_source_docker_registry_image.go +++ b/docker/data_source_docker_registry_image.go @@ -104,8 +104,12 @@ func getImageDigest(registry, image, tag, username, password string, fallback bo req.SetBasicAuth(username, password) } - // Set this header so that we get the v2 manifest back from the registry. - req.Header.Set("Accept", "application/vnd.docker.distribution.manifest.v2+json") + // We accept schema v2 manifests and manifest lists, and also OCI types + req.Header.Add("Accept", "application/vnd.docker.distribution.manifest.v2+json") + req.Header.Add("Accept", "application/vnd.docker.distribution.manifest.list.v2+json") + req.Header.Add("Accept", "application/vnd.oci.image.manifest.v1+json") + req.Header.Add("Accept", "application/vnd.oci.image.index.v1+json") + if fallback { // Fallback to this header if the registry does not support the v2 manifest like gcr.io req.Header.Set("Accept", "application/vnd.docker.distribution.manifest.v1+prettyjws") diff --git a/docker/resource_docker_registry_image_funcs.go b/docker/resource_docker_registry_image_funcs.go index d7987ba1..20c98988 100644 --- a/docker/resource_docker_registry_image_funcs.go +++ b/docker/resource_docker_registry_image_funcs.go @@ -346,8 +346,12 @@ func deleteDockerRegistryImage(pushOpts internalPushImageOptions, sha256Digest, req.SetBasicAuth(username, password) } - // Set this header so that we get the v2 manifest back from the registry. - req.Header.Set("Accept", "application/vnd.docker.distribution.manifest.v2+json") + // We accept schema v2 manifests and manifest lists, and also OCI types + req.Header.Add("Accept", "application/vnd.docker.distribution.manifest.v2+json") + req.Header.Add("Accept", "application/vnd.docker.distribution.manifest.list.v2+json") + req.Header.Add("Accept", "application/vnd.oci.image.manifest.v1+json") + req.Header.Add("Accept", "application/vnd.oci.image.index.v1+json") + if fallback { // Fallback to this header if the registry does not support the v2 manifest like gcr.io req.Header.Set("Accept", "application/vnd.docker.distribution.manifest.v1+prettyjws")