pkg/reference: Spec.Digest(): inline SplitObject code

Inline the relevant code from SplitObject, as we're only interested
in the digest portion.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2024-06-27 11:57:42 +02:00
parent 42145950bb
commit a5fce38f31
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C

View File

@ -135,8 +135,12 @@ func (r Spec) Hostname() string {
// Digest returns the digest portion of the reference spec. This may be a
// partial or invalid digest, which may be used to lookup a complete digest.
func (r Spec) Digest() digest.Digest {
_, dgst := SplitObject(r.Object)
return dgst
i := strings.Index(r.Object, "@")
if i < 0 {
return ""
}
return digest.Digest(r.Object[i+1:])
}
// String returns the normalized string for the ref.