reference
reference copied to clipboard
When reference.Parse returns a digest only ref?
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.
Parse() returns Reference. Reference is an interface type whose underlying type may or may not have a digest based on the regexp match:
https://github.com/distribution/reference/blob/ff14fafe2236e51c2894ac07d4bdfc778e96d682/reference.go#L217-L223
The underlying type returned by Parse is reference
https://github.com/distribution/reference/blob/ff14fafe2236e51c2894ac07d4bdfc778e96d682/reference.go#L356
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:
https://github.com/distribution/reference/blob/ff14fafe2236e51c2894ac07d4bdfc778e96d682/reference.go#L142
If the ref implements the Canonical, it also implements the Named.
https://github.com/distribution/reference/blob/ff14fafe2236e51c2894ac07d4bdfc778e96d682/reference.go#L330-L336
It seems that Parse accepts a digest only ref, but I don't know what it looks like.
Let's circle back.
Can you please explain what it is you are trying to achieve? Provide some code if possible. It's hard to explain things when there is no clear question.
I use the Parse to parse my ref, but cannot cover all cases in UT. I just want to know a valid input which may output a unnamed Reference