Skip to content

Commit

Permalink
Implement crane digest using a HEAD request (#784)
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh committed Oct 13, 2020
1 parent c9d94b7 commit e39e523
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/crane/digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package crane

// Digest returns the sha256 hash of the remote image at ref.
func Digest(ref string, opt ...Option) (string, error) {
desc, err := getManifest(ref, opt...)
desc, err := head(ref, opt...)
if err != nil {
return "", err
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/crane/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,12 @@ func getManifest(r string, opt ...Option) (*remote.Descriptor, error) {
}
return remote.Get(ref, o.remote...)
}

func head(r string, opt ...Option) (*v1.Descriptor, error) {
o := makeOptions(opt...)
ref, err := name.ParseReference(r, o.name...)
if err != nil {
return nil, err
}
return remote.Head(ref, o.remote...)
}

0 comments on commit e39e523

Please sign in to comment.