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

Method Untag

libimage/image.go:547–593  ·  view source on GitHub ↗

Untag the image with the specified name and make the change persistent 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

545// the local containers storage. The name is normalized according to the rules
546// of NormalizeName.
547func (i *Image) Untag(name string) error {
548 if strings.HasPrefix(name, "sha256:") { // ambiguous input
549 return errors.Wrap(errUntagDigest, name)
550 }
551
552 ref, err := NormalizeName(name)
553 if err != nil {
554 return errors.Wrapf(err, "normalizing name %q", name)
555 }
556
557 // FIXME: this is breaking Podman CI but must be re-enabled once
558 // c/storage supports alterting the digests of an image. Then,
559 // Podman will do the right thing.
560 //
561 // !!! Also make sure to re-enable the tests !!!
562 //
563 // if _, isDigested := ref.(reference.Digested); isDigested {
564 // return errors.Wrap(errUntagDigest, name)
565 // }
566
567 name = ref.String()
568
569 logrus.Debugf("Untagging %q from image %s", ref.String(), i.ID())
570 if i.runtime.eventChannel != nil {
571 defer i.runtime.writeEvent(&Event{ID: i.ID(), Name: name, Time: time.Now(), Type: EventTypeImageUntag})
572 }
573
574 removedName := false
575 newNames := []string{}
576 for _, n := range i.Names() {
577 if n == name {
578 removedName = true
579 continue
580 }
581 newNames = append(newNames, n)
582 }
583
584 if !removedName {
585 return errors.Wrap(errTagUnknown, name)
586 }
587
588 if err := i.runtime.store.SetNames(i.ID(), newNames); err != nil {
589 return err
590 }
591
592 return i.reload()
593}
594
595// RepoTags returns a string slice of repotags associated with the image.
596func (i *Image) RepoTags() ([]string, error) {

Callers 2

removeRecursiveMethod · 0.95
TestUntagFunction · 0.80

Calls 6

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

Tested by 1

TestUntagFunction · 0.64