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)
| 545 | // the local containers storage. The name is normalized according to the rules |
| 546 | // of NormalizeName. |
| 547 | func (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. |
| 596 | func (i *Image) RepoTags() ([]string, error) { |