Validate adding digests to tagstore with go types

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: 20e759ab56e9c17cfe0fbe839cdd4ac9ee6f0752
Component: engine
This commit is contained in:
Tonis Tiigi
2015-11-25 15:06:51 -08:00
parent 60f58722cf
commit c91b830a96
9 changed files with 98 additions and 35 deletions
+5 -9
View File
@@ -1024,20 +1024,16 @@ func (daemon *Daemon) changes(container *Container) ([]archive.Change, error) {
// imageName. If force is true, an existing tag with the same name may be
// overwritten.
func (daemon *Daemon) TagImage(newTag reference.Named, imageName string, force bool) error {
if _, isDigested := newTag.(reference.Digested); isDigested {
return errors.New("refusing to create a tag with a digest reference")
}
if newTag.Name() == string(digest.Canonical) {
return errors.New("refusing to create an ambiguous tag using digest algorithm as name")
}
newTag = registry.NormalizeLocalReference(newTag)
imageID, err := daemon.GetImageID(imageName)
if err != nil {
return err
}
newTag = registry.NormalizeLocalReference(newTag)
if err := daemon.tagStore.AddTag(newTag, imageID, force); err != nil {
return err
}
daemon.EventsService.Log("tag", newTag.String(), "")
return daemon.tagStore.Add(newTag, imageID, force)
return nil
}
// PullImage initiates a pull operation. image is the repository name to pull, and
+1 -1
View File
@@ -195,7 +195,7 @@ func restoreCustomImage(driver graphdriver.Driver, is image.Store, ls layer.Stor
return err
}
if err := ts.Add(ref, id, true); err != nil {
if err := ts.AddTag(ref, id, true); err != nil {
return err
}