ensure progress downloader is well formated

This commit is contained in:
Victor Vieux 2013-05-30 17:00:42 +00:00
commit cd002a4d16
8 changed files with 108 additions and 82 deletions

22
api.go
View File

@ -67,7 +67,16 @@ func getBoolParam(value string) (bool, error) {
} }
func getAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { func getAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
b, err := json.Marshal(srv.registry.GetAuthConfig(false)) // FIXME: Handle multiple login at once
// FIXME: return specific error code if config file missing?
authConfig, err := auth.LoadConfig(srv.runtime.root)
if err != nil {
if err != auth.ErrConfigFileMissing {
return err
}
authConfig = &auth.AuthConfig{}
}
b, err := json.Marshal(&auth.AuthConfig{Username: authConfig.Username, Email: authConfig.Email})
if err != nil { if err != nil {
return err return err
} }
@ -76,11 +85,19 @@ func getAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Reques
} }
func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
// FIXME: Handle multiple login at once
config := &auth.AuthConfig{} config := &auth.AuthConfig{}
if err := json.NewDecoder(r.Body).Decode(config); err != nil { if err := json.NewDecoder(r.Body).Decode(config); err != nil {
return err return err
} }
authConfig := srv.registry.GetAuthConfig(true)
authConfig, err := auth.LoadConfig(srv.runtime.root)
if err != nil {
if err != auth.ErrConfigFileMissing {
return err
}
authConfig = &auth.AuthConfig{}
}
if config.Username == authConfig.Username { if config.Username == authConfig.Username {
config.Password = authConfig.Password config.Password = authConfig.Password
} }
@ -90,7 +107,6 @@ func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Reque
if err != nil { if err != nil {
return err return err
} }
srv.registry.ResetClient(newAuthConfig)
if status != "" { if status != "" {
b, err := json.Marshal(&ApiAuth{Status: status}) b, err := json.Marshal(&ApiAuth{Status: status})

View File

@ -27,7 +27,6 @@ func TestGetAuth(t *testing.T) {
srv := &Server{ srv := &Server{
runtime: runtime, runtime: runtime,
registry: registry.NewRegistry(runtime.root),
} }
r := httptest.NewRecorder() r := httptest.NewRecorder()
@ -56,7 +55,7 @@ func TestGetAuth(t *testing.T) {
t.Fatalf("%d OK or 0 expected, received %d\n", http.StatusOK, r.Code) t.Fatalf("%d OK or 0 expected, received %d\n", http.StatusOK, r.Code)
} }
newAuthConfig := srv.registry.GetAuthConfig(false) newAuthConfig := registry.NewRegistry(runtime.root).GetAuthConfig(false)
if newAuthConfig.Username != authConfig.Username || if newAuthConfig.Username != authConfig.Username ||
newAuthConfig.Email != authConfig.Email { newAuthConfig.Email != authConfig.Email {
t.Fatalf("The auth configuration hasn't been set correctly") t.Fatalf("The auth configuration hasn't been set correctly")
@ -248,7 +247,6 @@ func TestGetImagesSearch(t *testing.T) {
srv := &Server{ srv := &Server{
runtime: runtime, runtime: runtime,
registry: registry.NewRegistry(runtime.root),
} }
r := httptest.NewRecorder() r := httptest.NewRecorder()
@ -505,14 +503,15 @@ func TestPostAuth(t *testing.T) {
srv := &Server{ srv := &Server{
runtime: runtime, runtime: runtime,
registry: registry.NewRegistry(runtime.root),
} }
authConfigOrig := &auth.AuthConfig{ config := &auth.AuthConfig{
Username: "utest", Username: "utest",
Email: "utest@yopmail.com", Email: "utest@yopmail.com",
} }
srv.registry.ResetClient(authConfigOrig)
authStr := auth.EncodeAuth(config)
auth.SaveConfig(runtime.root, authStr, config.Email)
r := httptest.NewRecorder() r := httptest.NewRecorder()
if err := getAuth(srv, API_VERSION, r, nil, nil); err != nil { if err := getAuth(srv, API_VERSION, r, nil, nil); err != nil {
@ -524,7 +523,7 @@ func TestPostAuth(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if authConfig.Username != authConfigOrig.Username || authConfig.Email != authConfigOrig.Email { if authConfig.Username != config.Username || authConfig.Email != config.Email {
t.Errorf("The retrieve auth mismatch with the one set.") t.Errorf("The retrieve auth mismatch with the one set.")
} }
} }

View File

@ -3,6 +3,7 @@ package auth
import ( import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -17,6 +18,12 @@ const CONFIGFILE = ".dockercfg"
// the registry server we want to login against // the registry server we want to login against
const INDEX_SERVER = "https://index.docker.io/v1" const INDEX_SERVER = "https://index.docker.io/v1"
//const INDEX_SERVER = "http://indexstaging-docker.dotcloud.com/"
var (
ErrConfigFileMissing error = errors.New("The Auth config file is missing")
)
type AuthConfig struct { type AuthConfig struct {
Username string `json:"username"` Username string `json:"username"`
Password string `json:"password"` Password string `json:"password"`
@ -75,7 +82,7 @@ func DecodeAuth(authStr string) (*AuthConfig, error) {
func LoadConfig(rootPath string) (*AuthConfig, error) { func LoadConfig(rootPath string) (*AuthConfig, error) {
confFile := path.Join(rootPath, CONFIGFILE) confFile := path.Join(rootPath, CONFIGFILE)
if _, err := os.Stat(confFile); err != nil { if _, err := os.Stat(confFile); err != nil {
return &AuthConfig{}, fmt.Errorf("The Auth config file is missing") return nil, ErrConfigFileMissing
} }
b, err := ioutil.ReadFile(confFile) b, err := ioutil.ReadFile(confFile)
if err != nil { if err != nil {
@ -97,7 +104,7 @@ func LoadConfig(rootPath string) (*AuthConfig, error) {
} }
// save the auth config // save the auth config
func saveConfig(rootPath, authStr string, email string) error { func SaveConfig(rootPath, authStr string, email string) error {
confFile := path.Join(rootPath, CONFIGFILE) confFile := path.Join(rootPath, CONFIGFILE)
if len(email) == 0 { if len(email) == 0 {
os.Remove(confFile) os.Remove(confFile)
@ -161,7 +168,9 @@ func Login(authConfig *AuthConfig) (string, error) {
status = "Login Succeeded\n" status = "Login Succeeded\n"
storeConfig = true storeConfig = true
} else if resp.StatusCode == 401 { } else if resp.StatusCode == 401 {
saveConfig(authConfig.rootPath, "", "") if err := SaveConfig(authConfig.rootPath, "", ""); err != nil {
return "", err
}
return "", fmt.Errorf("Wrong login/password, please try again") return "", fmt.Errorf("Wrong login/password, please try again")
} else { } else {
return "", fmt.Errorf("Login: %s (Code: %d; Headers: %s)", body, return "", fmt.Errorf("Login: %s (Code: %d; Headers: %s)", body,
@ -175,7 +184,9 @@ func Login(authConfig *AuthConfig) (string, error) {
} }
if storeConfig { if storeConfig {
authStr := EncodeAuth(authConfig) authStr := EncodeAuth(authConfig)
saveConfig(authConfig.rootPath, authStr, authConfig.Email) if err := SaveConfig(authConfig.rootPath, authStr, authConfig.Email); err != nil {
return "", err
}
} }
return status, nil return status, nil
} }

View File

@ -73,37 +73,37 @@ func (cli *DockerCli) CmdHelp(args ...string) error {
} }
} }
help := fmt.Sprintf("Usage: docker [OPTIONS] COMMAND [arg...]\n -H=\"%s:%d\": Host:port to bind/connect to\n\nA self-sufficient runtime for linux containers.\n\nCommands:\n", cli.host, cli.port) help := fmt.Sprintf("Usage: docker [OPTIONS] COMMAND [arg...]\n -H=\"%s:%d\": Host:port to bind/connect to\n\nA self-sufficient runtime for linux containers.\n\nCommands:\n", cli.host, cli.port)
for cmd, description := range map[string]string{ for _, command := range [][2]string{
"attach": "Attach to a running container", {"attach", "Attach to a running container"},
"build": "Build a container from a Dockerfile", {"build", "Build a container from a Dockerfile"},
"commit": "Create a new image from a container's changes", {"commit", "Create a new image from a container's changes"},
"diff": "Inspect changes on a container's filesystem", {"diff", "Inspect changes on a container's filesystem"},
"export": "Stream the contents of a container as a tar archive", {"export", "Stream the contents of a container as a tar archive"},
"history": "Show the history of an image", {"history", "Show the history of an image"},
"images": "List images", {"images", "List images"},
"import": "Create a new filesystem image from the contents of a tarball", {"import", "Create a new filesystem image from the contents of a tarball"},
"info": "Display system-wide information", {"info", "Display system-wide information"},
"insert": "Insert a file in an image", {"insert", "Insert a file in an image"},
"inspect": "Return low-level information on a container", {"inspect", "Return low-level information on a container"},
"kill": "Kill a running container", {"kill", "Kill a running container"},
"login": "Register or Login to the docker registry server", {"login", "Register or Login to the docker registry server"},
"logs": "Fetch the logs of a container", {"logs", "Fetch the logs of a container"},
"port": "Lookup the public-facing port which is NAT-ed to PRIVATE_PORT", {"port", "Lookup the public-facing port which is NAT-ed to PRIVATE_PORT"},
"ps": "List containers", {"ps", "List containers"},
"pull": "Pull an image or a repository from the docker registry server", {"pull", "Pull an image or a repository from the docker registry server"},
"push": "Push an image or a repository to the docker registry server", {"push", "Push an image or a repository to the docker registry server"},
"restart": "Restart a running container", {"restart", "Restart a running container"},
"rm": "Remove a container", {"rm", "Remove a container"},
"rmi": "Remove an image", {"rmi", "Remove an image"},
"run": "Run a command in a new container", {"run", "Run a command in a new container"},
"search": "Search for an image in the docker index", {"search", "Search for an image in the docker index"},
"start": "Start a stopped container", {"start", "Start a stopped container"},
"stop": "Stop a running container", {"stop", "Stop a running container"},
"tag": "Tag an image into a repository", {"tag", "Tag an image into a repository"},
"version": "Show the docker version information", {"version", "Show the docker version information"},
"wait": "Block until a container stops, then print its exit code", {"wait", "Block until a container stops}, then print its exit code"},
} { } {
help += fmt.Sprintf(" %-10.10s%s\n", cmd, description) help += fmt.Sprintf(" %-10.10s%s\n", command[0], command[1])
} }
fmt.Println(help) fmt.Println(help)
return nil return nil
@ -367,12 +367,10 @@ func (cli *DockerCli) CmdWait(args ...string) error {
// 'docker version': show version information // 'docker version': show version information
func (cli *DockerCli) CmdVersion(args ...string) error { func (cli *DockerCli) CmdVersion(args ...string) error {
cmd := Subcmd("version", "", "Show the docker version information.") cmd := Subcmd("version", "", "Show the docker version information.")
fmt.Println(len(args))
if err := cmd.Parse(args); err != nil { if err := cmd.Parse(args); err != nil {
return nil return nil
} }
fmt.Println(cmd.NArg())
if cmd.NArg() > 0 { if cmd.NArg() > 0 {
cmd.Usage() cmd.Usage()
return nil return nil

View File

@ -330,6 +330,9 @@ func (r *Registry) PushImageJsonIndex(remote string, imgList []*ImgData, validat
if validate { if validate {
suffix = "images" suffix = "images"
} }
utils.Debugf("Image list pushed to index:\n%s\n", imgListJson)
req, err := http.NewRequest("PUT", auth.IndexServerAddress()+"/repositories/"+remote+"/"+suffix, bytes.NewReader(imgListJson)) req, err := http.NewRequest("PUT", auth.IndexServerAddress()+"/repositories/"+remote+"/"+suffix, bytes.NewReader(imgListJson))
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -2,7 +2,6 @@ package docker
import ( import (
"fmt" "fmt"
"github.com/dotcloud/docker/registry"
"github.com/dotcloud/docker/utils" "github.com/dotcloud/docker/utils"
"io" "io"
"io/ioutil" "io/ioutil"
@ -64,7 +63,6 @@ func init() {
// Create the "Server" // Create the "Server"
srv := &Server{ srv := &Server{
runtime: runtime, runtime: runtime,
registry: registry.NewRegistry(runtime.root),
} }
// Retrieve the Image // Retrieve the Image
if err := srv.ImagePull(unitTestImageName, "", "", os.Stdout, utils.NewStreamFormatter(false)); err != nil { if err := srv.ImagePull(unitTestImageName, "", "", os.Stdout, utils.NewStreamFormatter(false)); err != nil {

View File

@ -49,7 +49,8 @@ func (srv *Server) ContainerExport(name string, out io.Writer) error {
} }
func (srv *Server) ImagesSearch(term string) ([]ApiSearch, error) { func (srv *Server) ImagesSearch(term string) ([]ApiSearch, error) {
results, err := srv.registry.SearchRepositories(term)
results, err := registry.NewRegistry(srv.runtime.root).SearchRepositories(term)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -291,8 +292,8 @@ func (srv *Server) ContainerTag(name, repo, tag string, force bool) error {
return nil return nil
} }
func (srv *Server) pullImage(out io.Writer, imgId, registry string, token []string, sf *utils.StreamFormatter) error { func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgId, endpoint string, token []string, sf *utils.StreamFormatter) error {
history, err := srv.registry.GetRemoteHistory(imgId, registry, token) history, err := r.GetRemoteHistory(imgId, endpoint, token)
if err != nil { if err != nil {
return err return err
} }
@ -302,7 +303,7 @@ func (srv *Server) pullImage(out io.Writer, imgId, registry string, token []stri
for _, id := range history { for _, id := range history {
if !srv.runtime.graph.Exists(id) { if !srv.runtime.graph.Exists(id) {
out.Write(sf.FormatStatus("Pulling %s metadata", id)) out.Write(sf.FormatStatus("Pulling %s metadata", id))
imgJson, err := srv.registry.GetRemoteImageJson(id, registry, token) imgJson, err := r.GetRemoteImageJson(id, endpoint, token)
if err != nil { if err != nil {
// FIXME: Keep goging in case of error? // FIXME: Keep goging in case of error?
return err return err
@ -314,7 +315,7 @@ func (srv *Server) pullImage(out io.Writer, imgId, registry string, token []stri
// Get the layer // Get the layer
out.Write(sf.FormatStatus("Pulling %s fs layer", id)) out.Write(sf.FormatStatus("Pulling %s fs layer", id))
layer, contentLength, err := srv.registry.GetRemoteImageLayer(img.Id, registry, token) layer, contentLength, err := r.GetRemoteImageLayer(img.Id, endpoint, token)
if err != nil { if err != nil {
return err return err
} }
@ -326,9 +327,9 @@ func (srv *Server) pullImage(out io.Writer, imgId, registry string, token []stri
return nil return nil
} }
func (srv *Server) pullRepository(out io.Writer, remote, askedTag string, sf *utils.StreamFormatter) error { func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, remote, askedTag string, sf *utils.StreamFormatter) error {
out.Write(sf.FormatStatus("Pulling repository %s from %s", remote, auth.IndexServerAddress())) out.Write(sf.FormatStatus("Pulling repository %s from %s", remote, auth.IndexServerAddress()))
repoData, err := srv.registry.GetRepositoryData(remote) repoData, err := r.GetRepositoryData(remote)
if err != nil { if err != nil {
return err return err
} }
@ -340,7 +341,7 @@ func (srv *Server) pullRepository(out io.Writer, remote, askedTag string, sf *ut
} }
utils.Debugf("Retrieving the tag list") utils.Debugf("Retrieving the tag list")
tagsList, err := srv.registry.GetRemoteTags(repoData.Endpoints, remote, repoData.Tokens) tagsList, err := r.GetRemoteTags(repoData.Endpoints, remote, repoData.Tokens)
if err != nil { if err != nil {
return err return err
} }
@ -367,7 +368,7 @@ func (srv *Server) pullRepository(out io.Writer, remote, askedTag string, sf *ut
out.Write(sf.FormatStatus("Pulling image %s (%s) from %s", img.Id, img.Tag, remote)) out.Write(sf.FormatStatus("Pulling image %s (%s) from %s", img.Id, img.Tag, remote))
success := false success := false
for _, ep := range repoData.Endpoints { for _, ep := range repoData.Endpoints {
if err := srv.pullImage(out, img.Id, "https://"+ep+"/v1", repoData.Tokens, sf); err != nil { if err := srv.pullImage(r, out, img.Id, "https://"+ep+"/v1", repoData.Tokens, sf); err != nil {
out.Write(sf.FormatStatus("Error while retrieving image for tag: %s (%s); checking next endpoint", askedTag, err)) out.Write(sf.FormatStatus("Error while retrieving image for tag: %s (%s); checking next endpoint", askedTag, err))
continue continue
} }
@ -393,16 +394,17 @@ func (srv *Server) pullRepository(out io.Writer, remote, askedTag string, sf *ut
return nil return nil
} }
func (srv *Server) ImagePull(name, tag, registry string, out io.Writer, sf *utils.StreamFormatter) error { func (srv *Server) ImagePull(name, tag, endpoint string, out io.Writer, sf *utils.StreamFormatter) error {
r := registry.NewRegistry(srv.runtime.root)
out = utils.NewWriteFlusher(out) out = utils.NewWriteFlusher(out)
if registry != "" { if endpoint != "" {
if err := srv.pullImage(out, name, registry, nil, sf); err != nil { if err := srv.pullImage(r, out, name, endpoint, nil, sf); err != nil {
return err return err
} }
return nil return nil
} }
if err := srv.pullRepository(out, name, tag, sf); err != nil { if err := srv.pullRepository(r, out, name, tag, sf); err != nil {
return err return err
} }
@ -475,7 +477,7 @@ func (srv *Server) getImageList(localRepo map[string]string) ([]*registry.ImgDat
return imgList, nil return imgList, nil
} }
func (srv *Server) pushRepository(out io.Writer, name string, localRepo map[string]string, sf *utils.StreamFormatter) error { func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name string, localRepo map[string]string, sf *utils.StreamFormatter) error {
out = utils.NewWriteFlusher(out) out = utils.NewWriteFlusher(out)
out.Write(sf.FormatStatus("Processing checksums")) out.Write(sf.FormatStatus("Processing checksums"))
imgList, err := srv.getImageList(localRepo) imgList, err := srv.getImageList(localRepo)
@ -484,12 +486,11 @@ func (srv *Server) pushRepository(out io.Writer, name string, localRepo map[stri
} }
out.Write(sf.FormatStatus("Sending image list")) out.Write(sf.FormatStatus("Sending image list"))
repoData, err := srv.registry.PushImageJsonIndex(name, imgList, false) repoData, err := r.PushImageJsonIndex(name, imgList, false)
if err != nil { if err != nil {
return err return err
} }
// FIXME: Send only needed images
for _, ep := range repoData.Endpoints { for _, ep := range repoData.Endpoints {
out.Write(sf.FormatStatus("Pushing repository %s to %s (%d tags)", name, ep, len(localRepo))) out.Write(sf.FormatStatus("Pushing repository %s to %s (%d tags)", name, ep, len(localRepo)))
// For each image within the repo, push them // For each image within the repo, push them
@ -498,24 +499,24 @@ func (srv *Server) pushRepository(out io.Writer, name string, localRepo map[stri
out.Write(sf.FormatStatus("Image %s already on registry, skipping", name)) out.Write(sf.FormatStatus("Image %s already on registry, skipping", name))
continue continue
} }
if err := srv.pushImage(out, name, elem.Id, ep, repoData.Tokens, sf); err != nil { if err := srv.pushImage(r, out, name, elem.Id, ep, repoData.Tokens, sf); err != nil {
// FIXME: Continue on error? // FIXME: Continue on error?
return err return err
} }
out.Write(sf.FormatStatus("Pushing tags for rev [%s] on {%s}", elem.Id, ep+"/users/"+name+"/"+elem.Tag)) out.Write(sf.FormatStatus("Pushing tags for rev [%s] on {%s}", elem.Id, ep+"/users/"+name+"/"+elem.Tag))
if err := srv.registry.PushRegistryTag(name, elem.Id, elem.Tag, ep, repoData.Tokens); err != nil { if err := r.PushRegistryTag(name, elem.Id, elem.Tag, ep, repoData.Tokens); err != nil {
return err return err
} }
} }
} }
if _, err := srv.registry.PushImageJsonIndex(name, imgList, true); err != nil { if _, err := r.PushImageJsonIndex(name, imgList, true); err != nil {
return err return err
} }
return nil return nil
} }
func (srv *Server) pushImage(out io.Writer, remote, imgId, ep string, token []string, sf *utils.StreamFormatter) error { func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgId, ep string, token []string, sf *utils.StreamFormatter) error {
out = utils.NewWriteFlusher(out) out = utils.NewWriteFlusher(out)
jsonRaw, err := ioutil.ReadFile(path.Join(srv.runtime.graph.Root, imgId, "json")) jsonRaw, err := ioutil.ReadFile(path.Join(srv.runtime.graph.Root, imgId, "json"))
if err != nil { if err != nil {
@ -534,7 +535,7 @@ func (srv *Server) pushImage(out io.Writer, remote, imgId, ep string, token []st
} }
// Send the json // Send the json
if err := srv.registry.PushImageJsonRegistry(imgData, jsonRaw, ep, token); err != nil { if err := r.PushImageJsonRegistry(imgData, jsonRaw, ep, token); err != nil {
if err == registry.ErrAlreadyExists { if err == registry.ErrAlreadyExists {
out.Write(sf.FormatStatus("Image %s already uploaded ; skipping", imgData.Id)) out.Write(sf.FormatStatus("Image %s already uploaded ; skipping", imgData.Id))
return nil return nil
@ -569,20 +570,22 @@ func (srv *Server) pushImage(out io.Writer, remote, imgId, ep string, token []st
} }
// Send the layer // Send the layer
if err := srv.registry.PushImageLayerRegistry(imgData.Id, utils.ProgressReader(layerData, int(layerData.Size), out, sf.FormatProgress("", "%v/%v (%v)"), sf), ep, token); err != nil { if err := r.PushImageLayerRegistry(imgData.Id, utils.ProgressReader(layerData, int(layerData.Size), out, sf.FormatProgress("", "%v/%v (%v)"), sf), ep, token); err != nil {
return err return err
} }
return nil return nil
} }
func (srv *Server) ImagePush(name, registry string, out io.Writer, sf *utils.StreamFormatter) error { func (srv *Server) ImagePush(name, endpoint string, out io.Writer, sf *utils.StreamFormatter) error {
out = utils.NewWriteFlusher(out) out = utils.NewWriteFlusher(out)
img, err := srv.runtime.graph.Get(name) img, err := srv.runtime.graph.Get(name)
r := registry.NewRegistry(srv.runtime.root)
if err != nil { if err != nil {
out.Write(sf.FormatStatus("The push refers to a repository [%s] (len: %d)", name, len(srv.runtime.repositories.Repositories[name]))) out.Write(sf.FormatStatus("The push refers to a repository [%s] (len: %d)", name, len(srv.runtime.repositories.Repositories[name])))
// If it fails, try to get the repository // If it fails, try to get the repository
if localRepo, exists := srv.runtime.repositories.Repositories[name]; exists { if localRepo, exists := srv.runtime.repositories.Repositories[name]; exists {
if err := srv.pushRepository(out, name, localRepo, sf); err != nil { if err := srv.pushRepository(r, out, name, localRepo, sf); err != nil {
return err return err
} }
return nil return nil
@ -591,7 +594,7 @@ func (srv *Server) ImagePush(name, registry string, out io.Writer, sf *utils.Str
return err return err
} }
out.Write(sf.FormatStatus("The push refers to an image: [%s]", name)) out.Write(sf.FormatStatus("The push refers to an image: [%s]", name))
if err := srv.pushImage(out, name, img.Id, registry, nil, sf); err != nil { if err := srv.pushImage(r, out, name, img.Id, endpoint, nil, sf); err != nil {
return err return err
} }
return nil return nil
@ -872,7 +875,6 @@ func NewServer(autoRestart bool) (*Server, error) {
} }
srv := &Server{ srv := &Server{
runtime: runtime, runtime: runtime,
registry: registry.NewRegistry(runtime.root),
} }
runtime.srv = srv runtime.srv = srv
return srv, nil return srv, nil
@ -880,5 +882,4 @@ func NewServer(autoRestart bool) (*Server, error) {
type Server struct { type Server struct {
runtime *Runtime runtime *Runtime
registry *registry.Registry
} }

View File

@ -105,7 +105,7 @@ func (r *progressReader) Close() error {
func ProgressReader(r io.ReadCloser, size int, output io.Writer, template []byte, sf *StreamFormatter) *progressReader { func ProgressReader(r io.ReadCloser, size int, output io.Writer, template []byte, sf *StreamFormatter) *progressReader {
tpl := string(template) tpl := string(template)
if tpl == "" { if tpl == "" {
tpl = "%v/%v (%v)" tpl = string(sf.FormatProgress("", "%v/%v (%v)"))
} }
return &progressReader{r, NewWriteFlusher(output), size, 0, 0, tpl, sf} return &progressReader{r, NewWriteFlusher(output), size, 0, 0, tpl, sf}
} }