Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When reference.Parse returns a digest only ref? #18

Open
liubog2008 opened this issue Dec 19, 2024 · 1 comment
Open

When reference.Parse returns a digest only ref? #18

liubog2008 opened this issue Dec 19, 2024 · 1 comment

Comments

@liubog2008
Copy link

I cannot see the test case in https://github.com/distribution/reference/blob/v0.6.0/reference_test.go#L14

It seems all are Named.

@milosgajdos
Copy link
Member

Parse() returns Reference. Reference is an interface type whose underlying type may or may not have a digest based on the regexp match:

reference/reference.go

Lines 217 to 223 in ff14faf

if matches[3] != "" {
var err error
ref.digest, err = digest.Parse(matches[3])
if err != nil {
return nil, err
}
}

The underlying type returned by Parse is reference

type reference struct {

The reference type implements Canonical interface so you will need to do a type assertion on it to check whether it implements Canonical interface which has a Digest method:

type Canonical interface {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants