Browse code

filters: don't encode empty set. API docs

Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)

Vincent Batts authored on 2014/05/31 05:42:37
Showing 3 changed files
... ...
@@ -1172,13 +1172,15 @@ func (cli *DockerCli) CmdImages(args ...string) error {
1172 1172
 	matchName := cmd.Arg(0)
1173 1173
 	// FIXME: --viz and --tree are deprecated. Remove them in a future version.
1174 1174
 	if *flViz || *flTree {
1175
-		filterJson, err := filters.ToParam(imageFilterArgs)
1176
-		if err != nil {
1177
-			return err
1178
-		}
1179 1175
 		v := url.Values{
1180
-			"all":     []string{"1"},
1181
-			"filters": []string{filterJson},
1176
+			"all": []string{"1"},
1177
+		}
1178
+		if len(imageFilterArgs) > 0 {
1179
+			filterJson, err := filters.ToParam(imageFilterArgs)
1180
+			if err != nil {
1181
+				return err
1182
+			}
1183
+			v.Set("filters", filterJson)
1182 1184
 		}
1183 1185
 
1184 1186
 		body, _, err := readBody(cli.call("GET", "/images/json?"+v.Encode(), nil, false))
... ...
@@ -1242,12 +1244,13 @@ func (cli *DockerCli) CmdImages(args ...string) error {
1242 1242
 			fmt.Fprintf(cli.out, " base [style=invisible]\n}\n")
1243 1243
 		}
1244 1244
 	} else {
1245
-		filterJson, err := filters.ToParam(imageFilterArgs)
1246
-		if err != nil {
1247
-			return err
1248
-		}
1249
-		v := url.Values{
1250
-			"filters": []string{filterJson},
1245
+		v := url.Values{}
1246
+		if len(imageFilterArgs) > 0 {
1247
+			filterJson, err := filters.ToParam(imageFilterArgs)
1248
+			if err != nil {
1249
+				return err
1250
+			}
1251
+			v.Set("filters", filterJson)
1251 1252
 		}
1252 1253
 
1253 1254
 		if cmd.NArg() == 1 {
... ...
@@ -712,6 +712,16 @@ Copy files or folders of container `id`
712 712
           }
713 713
         ]
714 714
 
715
+
716
+    Query Parameters:
717
+
718
+     
719
+
720
+    -   **all** – 1/True/true or 0/False/false, default false
721
+    -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the images list.
722
+        
723
+
724
+
715 725
 ### Create an image
716 726
 
717 727
 `POST /images/create`
... ...
@@ -712,7 +712,7 @@ func (srv *Server) Images(job *engine.Job) engine.Status {
712 712
 		}
713 713
 	}
714 714
 
715
-	if job.GetenvBool("all") && !filt_tagged {
715
+	if job.GetenvBool("all") && filt_tagged {
716 716
 		allImages, err = srv.daemon.Graph().Map()
717 717
 	} else {
718 718
 		allImages, err = srv.daemon.Graph().Heads()