mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
0380fbff37
Signed-off-by: John Howard <jhoward@microsoft.com> This PR has the API changes described in https://github.com/moby/moby/issues/34617. Specifically, it adds an HTTP header "X-Requested-Platform" which is a JSON-encoded OCI Image-spec `Platform` structure. In addition, it renames (almost all) uses of a string variable platform (and associated) methods/functions to os. This makes it much clearer to disambiguate with the swarm "platform" which is really os/arch. This is a stepping stone to getting the daemon towards fully multi-platform/arch-aware, and makes it clear when "operating system" is being referred to rather than "platform" which is misleadingly used - sometimes in the swarm meaning, but more often as just the operating system.
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package daemon
|
|
|
|
import (
|
|
"github.com/docker/distribution/reference"
|
|
"github.com/docker/docker/image"
|
|
)
|
|
|
|
// TagImage creates the tag specified by newTag, pointing to the image named
|
|
// imageName (alternatively, imageName can also be an image ID).
|
|
func (daemon *Daemon) TagImage(imageName, repository, tag string) error {
|
|
imageID, os, err := daemon.GetImageIDAndOS(imageName)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
newTag, err := reference.ParseNormalizedNamed(repository)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if tag != "" {
|
|
if newTag, err = reference.WithTag(reference.TrimNamed(newTag), tag); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return daemon.TagImageWithReference(imageID, os, newTag)
|
|
}
|
|
|
|
// TagImageWithReference adds the given reference to the image ID provided.
|
|
func (daemon *Daemon) TagImageWithReference(imageID image.ID, os string, newTag reference.Named) error {
|
|
if err := daemon.referenceStore.AddTag(newTag, imageID.Digest(), true); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := daemon.stores[os].imageStore.SetLastUpdated(imageID); err != nil {
|
|
return err
|
|
}
|
|
daemon.LogImageEvent(imageID.String(), reference.FamiliarString(newTag), "tag")
|
|
return nil
|
|
}
|