Browse code

refactor and fix tests

Victor Vieux authored on 2013/12/10 09:25:19
Showing 2 changed files
... ...
@@ -905,15 +905,17 @@ func postBuild(srv *Server, version float64, w http.ResponseWriter, r *http.Requ
905 905
 	if version < 1.3 {
906 906
 		return fmt.Errorf("Multipart upload for build is no longer supported. Please upgrade your docker client.")
907 907
 	}
908
-	remoteURL := r.FormValue("remote")
909
-	repoName := r.FormValue("t")
910
-	rawSuppressOutput := r.FormValue("q")
911
-	rawNoCache := r.FormValue("nocache")
912
-	rawRm := r.FormValue("rm")
913
-	repoName, tag := utils.ParseRepositoryTag(repoName)
914
-
915
-	authEncoded := r.Header.Get("X-Registry-Auth")
916
-	authConfig := &auth.AuthConfig{}
908
+	var (
909
+		remoteURL         = r.FormValue("remote")
910
+		repoName          = r.FormValue("t")
911
+		rawSuppressOutput = r.FormValue("q")
912
+		rawNoCache        = r.FormValue("nocache")
913
+		rawRm             = r.FormValue("rm")
914
+		authEncoded       = r.Header.Get("X-Registry-Auth")
915
+		authConfig        = &auth.AuthConfig{}
916
+		tag               string
917
+	)
918
+	repoName, tag = utils.ParseRepositoryTag(repoName)
917 919
 	if authEncoded != "" {
918 920
 		authJson := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authEncoded))
919 921
 		if err := json.NewDecoder(authJson).Decode(authConfig); err != nil {
... ...
@@ -266,7 +266,7 @@ func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, u
266 266
 	}
267 267
 	dockerfile := constructDockerfile(context.dockerfile, ip, port)
268 268
 
269
-	buildfile := docker.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, useCache, false, ioutil.Discard, utils.NewStreamFormatter(false))
269
+	buildfile := docker.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, useCache, false, ioutil.Discard, utils.NewStreamFormatter(false), nil)
270 270
 	id, err := buildfile.Build(mkTestContext(dockerfile, context.files, t))
271 271
 	if err != nil {
272 272
 		return nil, err
... ...
@@ -516,7 +516,7 @@ func TestForbiddenContextPath(t *testing.T) {
516 516
 	}
517 517
 	dockerfile := constructDockerfile(context.dockerfile, ip, port)
518 518
 
519
-	buildfile := docker.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, true, false, ioutil.Discard, utils.NewStreamFormatter(false))
519
+	buildfile := docker.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, true, false, ioutil.Discard, utils.NewStreamFormatter(false), nil)
520 520
 	_, err = buildfile.Build(mkTestContext(dockerfile, context.files, t))
521 521
 
522 522
 	if err == nil {
... ...
@@ -562,7 +562,7 @@ func TestBuildADDFileNotFound(t *testing.T) {
562 562
 	}
563 563
 	dockerfile := constructDockerfile(context.dockerfile, ip, port)
564 564
 
565
-	buildfile := docker.NewBuildFile(mkServerFromEngine(eng, t), ioutil.Discard, ioutil.Discard, false, true, false, ioutil.Discard, utils.NewStreamFormatter(false))
565
+	buildfile := docker.NewBuildFile(mkServerFromEngine(eng, t), ioutil.Discard, ioutil.Discard, false, true, false, ioutil.Discard, utils.NewStreamFormatter(false), nil)
566 566
 	_, err = buildfile.Build(mkTestContext(dockerfile, context.files, t))
567 567
 
568 568
 	if err == nil {