MCPcopy Create free account
hub / github.com/containers/common / Tag

Method Tag

libimage/image.go:510–535  ·  view source on GitHub ↗

Tag the image with the specified name and store it in the local containers storage. The name is normalized according to the rules of NormalizeName.

(name string)

Source from the content-addressed store, hash-verified

508// Tag the image with the specified name and store it in the local containers
509// storage. The name is normalized according to the rules of NormalizeName.
510func (i *Image) Tag(name string) error {
511 if strings.HasPrefix(name, "sha256:") { // ambiguous input
512 return errors.Wrap(errTagDigest, name)
513 }
514
515 ref, err := NormalizeName(name)
516 if err != nil {
517 return errors.Wrapf(err, "normalizing name %q", name)
518 }
519
520 if _, isDigested := ref.(reference.Digested); isDigested {
521 return errors.Wrap(errTagDigest, name)
522 }
523
524 logrus.Debugf("Tagging image %s with %q", i.ID(), ref.String())
525 if i.runtime.eventChannel != nil {
526 defer i.runtime.writeEvent(&Event{ID: i.ID(), Name: name, Time: time.Now(), Type: EventTypeImageTag})
527 }
528
529 newNames := append(i.Names(), ref.String())
530 if err := i.runtime.store.SetNames(i.ID(), newNames); err != nil {
531 return err
532 }
533
534 return i.reload()
535}
536
537// to have some symmetry with the errors from containers/storage.
538var errTagUnknown = errors.New("tag not known")

Callers 10

ToNameTagPairsFunction · 0.80
inRepoTagsMethod · 0.80
TestTagFunction · 0.80
TestUntagFunction · 0.80
ImportMethod · 0.80
TestFilterReferenceFunction · 0.80
TestRemoveImagesFunction · 0.80

Calls 6

IDMethod · 0.95
NamesMethod · 0.95
reloadMethod · 0.95
NormalizeNameFunction · 0.85
writeEventMethod · 0.80
StringMethod · 0.45

Tested by 7

TestTagFunction · 0.64
TestUntagFunction · 0.64
TestFilterReferenceFunction · 0.64
TestRemoveImagesFunction · 0.64