(transport storageTransport, named reference.Named, id string)
| 28 | } |
| 29 | |
| 30 | func newReference(transport storageTransport, named reference.Named, id string) (*storageReference, error) { |
| 31 | if named == nil && id == "" { |
| 32 | return nil, ErrInvalidReference |
| 33 | } |
| 34 | if named != nil && reference.IsNameOnly(named) { |
| 35 | return nil, fmt.Errorf("reference %s has neither a tag nor a digest: %w", named.String(), ErrInvalidReference) |
| 36 | } |
| 37 | if id != "" { |
| 38 | if err := validateImageID(id); err != nil { |
| 39 | return nil, fmt.Errorf("invalid ID value %q: %v: %w", id, err.Error(), ErrInvalidReference) |
| 40 | } |
| 41 | } |
| 42 | // We take a copy of the transport, which contains a pointer to the |
| 43 | // store that it used for resolving this reference, so that the |
| 44 | // transport that we'll return from Transport() won't be affected by |
| 45 | // further calls to the original transport's SetStore() method. |
| 46 | return &storageReference{ |
| 47 | transport: transport, |
| 48 | named: named, |
| 49 | id: id, |
| 50 | }, nil |
| 51 | } |
| 52 | |
| 53 | // imageMatchesRepo returns true iff image.Names contains an element with the same repo as ref |
| 54 | func imageMatchesRepo(image *storage.Image, ref reference.Named) bool { |
searching dependent graphs…