Skip to content

Commit

Permalink
Implement crane.Head (#1057)
Browse files Browse the repository at this point in the history
This returns a v1.Descriptor, so it's possible to detect the media type,
digest, and size of a remote artifact.
  • Loading branch information
jonjohnsonjr committed Jun 21, 2021
1 parent 3bfd0b5 commit 5f53e4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/crane/digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func Digest(ref string, opt ...Option) (string, error) {
}
return digest.String(), nil
}
desc, err := head(ref, opt...)
desc, err := Head(ref, opt...)
if err != nil {
logs.Warn.Printf("HEAD request failed, falling back on GET: %v", err)
rdesc, err := getManifest(ref, opt...)
Expand Down
4 changes: 3 additions & 1 deletion pkg/crane/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func getManifest(r string, opt ...Option) (*remote.Descriptor, error) {
return remote.Get(ref, o.remote...)
}

func head(r string, opt ...Option) (*v1.Descriptor, error) {
// Head performs a HEAD request for a manifest and returns a content descriptor
// based on the registry's response.
func Head(r string, opt ...Option) (*v1.Descriptor, error) {
o := makeOptions(opt...)
ref, err := name.ParseReference(r, o.name...)
if err != nil {
Expand Down

0 comments on commit 5f53e4e

Please sign in to comment.