Merge pull request #16638 from MHBauer/daemon-derepo
refactor daemon image tagging
This commit is contained in:
commit
67e38cc54c
2 changed files with 74 additions and 10 deletions
|
@ -123,7 +123,7 @@ func (s *router) postImagesCreate(ctx context.Context, w http.ResponseWriter, r
|
|||
OutStream: output,
|
||||
}
|
||||
|
||||
err = s.daemon.Repositories().Pull(image, tag, imagePullConfig)
|
||||
err = s.daemon.PullImage(image, tag, imagePullConfig)
|
||||
} else { //import
|
||||
if tag == "" {
|
||||
repo, tag = parsers.ParseRepositoryTag(repo)
|
||||
|
@ -140,7 +140,7 @@ func (s *router) postImagesCreate(ctx context.Context, w http.ResponseWriter, r
|
|||
return err
|
||||
}
|
||||
|
||||
err = s.daemon.Repositories().Import(src, repo, tag, message, r.Body, output, newConfig)
|
||||
err = s.daemon.ImportImage(src, repo, tag, message, r.Body, output, newConfig)
|
||||
}
|
||||
if err != nil {
|
||||
if !output.Flushed() {
|
||||
|
@ -195,7 +195,7 @@ func (s *router) postImagesPush(ctx context.Context, w http.ResponseWriter, r *h
|
|||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
if err := s.daemon.Repositories().Push(name, imagePushConfig); err != nil {
|
||||
if err := s.daemon.PushImage(name, imagePushConfig); err != nil {
|
||||
if !output.Flushed() {
|
||||
return err
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ func (s *router) getImagesGet(ctx context.Context, w http.ResponseWriter, r *htt
|
|||
names = r.Form["names"]
|
||||
}
|
||||
|
||||
if err := s.daemon.Repositories().ImageExport(names, output); err != nil {
|
||||
if err := s.daemon.ExportImage(names, output); err != nil {
|
||||
if !output.Flushed() {
|
||||
return err
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ func (s *router) getImagesGet(ctx context.Context, w http.ResponseWriter, r *htt
|
|||
}
|
||||
|
||||
func (s *router) postImagesLoad(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||
return s.daemon.Repositories().Load(r.Body, w)
|
||||
return s.daemon.LoadImage(r.Body, w)
|
||||
}
|
||||
|
||||
func (s *router) deleteImages(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||
|
@ -267,7 +267,7 @@ func (s *router) getImagesByName(ctx context.Context, w http.ResponseWriter, r *
|
|||
return fmt.Errorf("Missing parameter")
|
||||
}
|
||||
|
||||
imageInspect, err := s.daemon.Repositories().Lookup(vars["name"])
|
||||
imageInspect, err := s.daemon.LookupImage(vars["name"])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ func (s *router) getImagesJSON(ctx context.Context, w http.ResponseWriter, r *ht
|
|||
}
|
||||
|
||||
// FIXME: The filter parameter could just be a match filter
|
||||
images, err := s.daemon.Repositories().Images(r.Form.Get("filters"), r.Form.Get("filter"), httputils.BoolValue(r, "all"))
|
||||
images, err := s.daemon.ListImages(r.Form.Get("filters"), r.Form.Get("filter"), httputils.BoolValue(r, "all"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ func (s *router) getImagesHistory(ctx context.Context, w http.ResponseWriter, r
|
|||
}
|
||||
|
||||
name := vars["name"]
|
||||
history, err := s.daemon.Repositories().History(name)
|
||||
history, err := s.daemon.ImageHistory(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -471,9 +471,9 @@ func (s *router) postImagesTag(ctx context.Context, w http.ResponseWriter, r *ht
|
|||
|
||||
repo := r.Form.Get("repo")
|
||||
tag := r.Form.Get("tag")
|
||||
force := httputils.BoolValue(r, "force")
|
||||
name := vars["name"]
|
||||
if err := s.daemon.Repositories().Tag(repo, tag, name, force); err != nil {
|
||||
force := httputils.BoolValue(r, "force")
|
||||
if err := s.daemon.TagImage(repo, tag, name, force); err != nil {
|
||||
return err
|
||||
}
|
||||
s.daemon.EventsService.Log("tag", utils.ImageReference(repo, tag), "")
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/api"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/daemon/events"
|
||||
"github.com/docker/docker/daemon/execdriver"
|
||||
"github.com/docker/docker/daemon/execdriver/execdrivers"
|
||||
|
@ -1015,6 +1016,69 @@ func (daemon *Daemon) Repositories() *graph.TagStore {
|
|||
return daemon.repositories
|
||||
}
|
||||
|
||||
// TagImage creates a tag in the repository reponame, pointing to the image named
|
||||
// imageName. If force is true, an existing tag with the same name may be
|
||||
// overwritten.
|
||||
func (daemon *Daemon) TagImage(repoName, tag, imageName string, force bool) error {
|
||||
return daemon.repositories.Tag(repoName, tag, imageName, force)
|
||||
}
|
||||
|
||||
// PullImage initiates a pull operation. image is the repository name to pull, and
|
||||
// tag may be either empty, or indicate a specific tag to pull.
|
||||
func (daemon *Daemon) PullImage(image string, tag string, imagePullConfig *graph.ImagePullConfig) error {
|
||||
return daemon.repositories.Pull(image, tag, imagePullConfig)
|
||||
}
|
||||
|
||||
// ImportImage imports an image, getting the archived layer data either from
|
||||
// inConfig (if src is "-"), or from a URI specified in src. Progress output is
|
||||
// written to outStream. Repository and tag names can optionally be given in
|
||||
// the repo and tag arguments, respectively.
|
||||
func (daemon *Daemon) ImportImage(src, repo, tag, msg string, inConfig io.ReadCloser, outStream io.Writer, containerConfig *runconfig.Config) error {
|
||||
return daemon.repositories.Import(src, repo, tag, msg, inConfig, outStream, containerConfig)
|
||||
}
|
||||
|
||||
// ExportImage exports a list of images to the given output stream. The
|
||||
// exported images are archived into a tar when written to the output
|
||||
// stream. All images with the given tag and all versions containing
|
||||
// the same tag are exported. names is the set of tags to export, and
|
||||
// outStream is the writer which the images are written to.
|
||||
func (daemon *Daemon) ExportImage(names []string, outStream io.Writer) error {
|
||||
return daemon.repositories.ImageExport(names, outStream)
|
||||
}
|
||||
|
||||
// PushImage initiates a push operation on the repository named localName.
|
||||
func (daemon *Daemon) PushImage(localName string, imagePushConfig *graph.ImagePushConfig) error {
|
||||
return daemon.repositories.Push(localName, imagePushConfig)
|
||||
}
|
||||
|
||||
// LookupImage looks up an image by name and returns it as an ImageInspect
|
||||
// structure.
|
||||
func (daemon *Daemon) LookupImage(name string) (*types.ImageInspect, error) {
|
||||
return daemon.repositories.Lookup(name)
|
||||
}
|
||||
|
||||
// LoadImage uploads a set of images into the repository. This is the
|
||||
// complement of ImageExport. The input stream is an uncompressed tar
|
||||
// ball containing images and metadata.
|
||||
func (daemon *Daemon) LoadImage(inTar io.ReadCloser, outStream io.Writer) error {
|
||||
return daemon.repositories.Load(inTar, outStream)
|
||||
}
|
||||
|
||||
// ListImages returns a filtered list of images. filterArgs is a JSON-encoded set
|
||||
// of filter arguments which will be interpreted by pkg/parsers/filters.
|
||||
// filter is a shell glob string applied to repository names. The argument
|
||||
// named all controls whether all images in the graph are filtered, or just
|
||||
// the heads.
|
||||
func (daemon *Daemon) ListImages(filterArgs, filter string, all bool) ([]*types.Image, error) {
|
||||
return daemon.repositories.Images(filterArgs, filter, all)
|
||||
}
|
||||
|
||||
// ImageHistory returns a slice of ImageHistory structures for the specified image
|
||||
// name by walking the image lineage.
|
||||
func (daemon *Daemon) ImageHistory(name string) ([]*types.ImageHistory, error) {
|
||||
return daemon.repositories.History(name)
|
||||
}
|
||||
|
||||
func (daemon *Daemon) config() *Config {
|
||||
return daemon.configStore
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue