From 8291f00a0e656cf3bb52fb1dcdff7c266305f4d5 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 9 Dec 2013 16:25:19 -0800 Subject: [PATCH] refactor and fix tests --- api.go | 20 +++++++++++--------- integration/buildfile_test.go | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/api.go b/api.go index fb59f5efd3..bd8e53d655 100644 --- a/api.go +++ b/api.go @@ -905,15 +905,17 @@ func postBuild(srv *Server, version float64, w http.ResponseWriter, r *http.Requ if version < 1.3 { return fmt.Errorf("Multipart upload for build is no longer supported. Please upgrade your docker client.") } - remoteURL := r.FormValue("remote") - repoName := r.FormValue("t") - rawSuppressOutput := r.FormValue("q") - rawNoCache := r.FormValue("nocache") - rawRm := r.FormValue("rm") - repoName, tag := utils.ParseRepositoryTag(repoName) - - authEncoded := r.Header.Get("X-Registry-Auth") - authConfig := &auth.AuthConfig{} + var ( + remoteURL = r.FormValue("remote") + repoName = r.FormValue("t") + rawSuppressOutput = r.FormValue("q") + rawNoCache = r.FormValue("nocache") + rawRm = r.FormValue("rm") + authEncoded = r.Header.Get("X-Registry-Auth") + authConfig = &auth.AuthConfig{} + tag string + ) + repoName, tag = utils.ParseRepositoryTag(repoName) if authEncoded != "" { authJson := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authEncoded)) if err := json.NewDecoder(authJson).Decode(authConfig); err != nil { diff --git a/integration/buildfile_test.go b/integration/buildfile_test.go index 242bf9f412..4d15031d30 100644 --- a/integration/buildfile_test.go +++ b/integration/buildfile_test.go @@ -266,7 +266,7 @@ func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, u } dockerfile := constructDockerfile(context.dockerfile, ip, port) - buildfile := docker.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, useCache, false, ioutil.Discard, utils.NewStreamFormatter(false)) + buildfile := docker.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, useCache, false, ioutil.Discard, utils.NewStreamFormatter(false), nil) id, err := buildfile.Build(mkTestContext(dockerfile, context.files, t)) if err != nil { return nil, err @@ -516,7 +516,7 @@ func TestForbiddenContextPath(t *testing.T) { } dockerfile := constructDockerfile(context.dockerfile, ip, port) - buildfile := docker.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, true, false, ioutil.Discard, utils.NewStreamFormatter(false)) + buildfile := docker.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, true, false, ioutil.Discard, utils.NewStreamFormatter(false), nil) _, err = buildfile.Build(mkTestContext(dockerfile, context.files, t)) if err == nil { @@ -562,7 +562,7 @@ func TestBuildADDFileNotFound(t *testing.T) { } dockerfile := constructDockerfile(context.dockerfile, ip, port) - buildfile := docker.NewBuildFile(mkServerFromEngine(eng, t), ioutil.Discard, ioutil.Discard, false, true, false, ioutil.Discard, utils.NewStreamFormatter(false)) + buildfile := docker.NewBuildFile(mkServerFromEngine(eng, t), ioutil.Discard, ioutil.Discard, false, true, false, ioutil.Discard, utils.NewStreamFormatter(false), nil) _, err = buildfile.Build(mkTestContext(dockerfile, context.files, t)) if err == nil {