mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 05:31:47 +00:00
Documentation improvements and code cleanups for graph package
Expand the godoc documentation for the graph package. Centralize DefaultTag in the graphs/tag package instead of defining it twice. Remove some unnecessary "config" structs that are only used to pass a few parameters to a function. Simplify the GetParentsSize function - there's no reason for it to take an accumulator argument. Unexport some functions that aren't needed outside the package. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
+1
-1
@@ -526,7 +526,7 @@ func rewriteDockerfileFrom(dockerfileName string, translator func(string, regist
|
||||
// Replace the line with a resolved "FROM repo@digest"
|
||||
repo, tag := parsers.ParseRepositoryTag(matches[1])
|
||||
if tag == "" {
|
||||
tag = tags.DEFAULTTAG
|
||||
tag = tags.DefaultTag
|
||||
}
|
||||
ref := registry.ParseReference(tag)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ func (cli *DockerCli) pullImageCustomOut(image string, out io.Writer) error {
|
||||
repos, tag := parsers.ParseRepositoryTag(image)
|
||||
// pull only the image tagged 'latest' if no tag was specified
|
||||
if tag == "" {
|
||||
tag = tags.DEFAULTTAG
|
||||
tag = tags.DefaultTag
|
||||
}
|
||||
v.Set("fromImage", repos)
|
||||
v.Set("tag", tag)
|
||||
@@ -96,7 +96,7 @@ func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runc
|
||||
|
||||
repo, tag := parsers.ParseRepositoryTag(config.Image)
|
||||
if tag == "" {
|
||||
tag = tags.DEFAULTTAG
|
||||
tag = tags.DefaultTag
|
||||
}
|
||||
|
||||
ref := registry.ParseReference(tag)
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ func (cli *DockerCli) CmdPull(args ...string) error {
|
||||
|
||||
taglessRemote, tag := parsers.ParseRepositoryTag(remote)
|
||||
if tag == "" && !*allTags {
|
||||
tag = tags.DEFAULTTAG
|
||||
tag = tags.DefaultTag
|
||||
fmt.Fprintf(cli.out, "Using default tag: %s\n", tag)
|
||||
} else if tag != "" && *allTags {
|
||||
return fmt.Errorf("tag can't be used with --all-tags/-a")
|
||||
|
||||
+8
-20
@@ -364,14 +364,8 @@ func (s *Server) getImagesJSON(version version.Version, w http.ResponseWriter, r
|
||||
return err
|
||||
}
|
||||
|
||||
imagesConfig := graph.ImagesConfig{
|
||||
Filters: r.Form.Get("filters"),
|
||||
// FIXME this parameter could just be a match filter
|
||||
Filter: r.Form.Get("filter"),
|
||||
All: boolValue(r, "all"),
|
||||
}
|
||||
|
||||
images, err := s.daemon.Repositories().Images(&imagesConfig)
|
||||
// FIXME: The filter parameter could just be a match filter
|
||||
images, err := s.daemon.Repositories().Images(r.Form.Get("filters"), r.Form.Get("filter"), boolValue(r, "all"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -785,23 +779,17 @@ func (s *Server) postImagesCreate(version version.Version, w http.ResponseWriter
|
||||
}
|
||||
|
||||
src := r.Form.Get("fromSrc")
|
||||
imageImportConfig := &graph.ImageImportConfig{
|
||||
Changes: r.Form["changes"],
|
||||
InConfig: r.Body,
|
||||
OutStream: output,
|
||||
}
|
||||
|
||||
// 'err' MUST NOT be defined within this block, we need any error
|
||||
// generated from the download to be available to the output
|
||||
// stream processing below
|
||||
var newConfig *runconfig.Config
|
||||
newConfig, err = builder.BuildFromConfig(s.daemon, &runconfig.Config{}, imageImportConfig.Changes)
|
||||
newConfig, err = builder.BuildFromConfig(s.daemon, &runconfig.Config{}, r.Form["changes"])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
imageImportConfig.ContainerConfig = newConfig
|
||||
|
||||
err = s.daemon.Repositories().Import(src, repo, tag, imageImportConfig)
|
||||
err = s.daemon.Repositories().Import(src, repo, tag, r.Body, output, newConfig)
|
||||
}
|
||||
if err != nil {
|
||||
if !output.Flushed() {
|
||||
@@ -909,14 +897,14 @@ func (s *Server) getImagesGet(version version.Version, w http.ResponseWriter, r
|
||||
w.Header().Set("Content-Type", "application/x-tar")
|
||||
|
||||
output := ioutils.NewWriteFlusher(w)
|
||||
imageExportConfig := &graph.ImageExportConfig{Outstream: output}
|
||||
var names []string
|
||||
if name, ok := vars["name"]; ok {
|
||||
imageExportConfig.Names = []string{name}
|
||||
names = []string{name}
|
||||
} else {
|
||||
imageExportConfig.Names = r.Form["names"]
|
||||
names = r.Form["names"]
|
||||
}
|
||||
|
||||
if err := s.daemon.Repositories().ImageExport(imageExportConfig); err != nil {
|
||||
if err := s.daemon.Repositories().ImageExport(names, output); err != nil {
|
||||
if !output.Flushed() {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user