MCPcopy Create free account
hub / github.com/containers/image / newReference

Function newReference

storage/storage_reference.go:30–51  ·  view source on GitHub ↗
(transport storageTransport, named reference.Named, id string)

Source from the content-addressed store, hash-verified

28}
29
30func 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
54func imageMatchesRepo(image *storage.Image, ref reference.Named) bool {

Callers 3

NewStoreReferenceMethod · 0.70
CommitWithOptionsMethod · 0.70
TestNewReferenceFunction · 0.70

Calls 4

IsNameOnlyFunction · 0.92
validateImageIDFunction · 0.85
StringMethod · 0.65
ErrorMethod · 0.45

Tested by 1

TestNewReferenceFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…