diff --git a/lib/docker_registry2.rb b/lib/docker_registry2.rb index a7740e5..b29f068 100644 --- a/lib/docker_registry2.rb +++ b/lib/docker_registry2.rb @@ -22,4 +22,8 @@ def self.tags(repository) def self.manifest(repository, tag) @reg.manifest(repository, tag) end + + def self.manifest_digest(repository, tag) + @reg.manifest_digest(repository, tag) + end end diff --git a/lib/registry/registry.rb b/lib/registry/registry.rb index edbbffe..5f804e0 100644 --- a/lib/registry/registry.rb +++ b/lib/registry/registry.rb @@ -126,6 +126,14 @@ def blob(repo, digest, outpath = nil) end end + def manifest_digest(repo, tag) + tag_path = "/v2/#{repo}/manifests/#{tag}" + dohead(tag_path).headers[:docker_content_digest] + rescue DockerRegistry2::InvalidMethod + # Pre-2.3.0 registries didn't support manifest HEAD requests + doget(tag_path).headers[:docker_content_digest] + end + def digest(image, tag, architecture = nil, os = nil, variant = nil) manifest = manifest(image, tag) parsed_manifest = JSON.parse(manifest.body)