Skip to content

Commit

Permalink
Reintroduce old digest functionality
Browse files Browse the repository at this point in the history
* This digest function executes HEAD requests instead of querying the manifest
* GET requests are ratelimited in some registries
  • Loading branch information
Manuel Dewald committed Jul 20, 2023
1 parent 153b31e commit ff75f52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/docker_registry2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions lib/registry/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ def blob(repo, digest, outpath = nil)
end
end

def manifest_digest(image, 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)
Expand Down

0 comments on commit ff75f52

Please sign in to comment.