Signed-off-by: Shijiang Wei <mountkin@gmail.com>
| ... | ... |
@@ -51,8 +51,10 @@ func (s *TagStore) Images(filterArgs, filter string, all bool) ([]*types.Image, |
| 51 | 51 |
|
| 52 | 52 |
if i, ok := imageFilters["dangling"]; ok {
|
| 53 | 53 |
for _, value := range i {
|
| 54 |
- if strings.ToLower(value) == "true" {
|
|
| 54 |
+ if v := strings.ToLower(value); v == "true" {
|
|
| 55 | 55 |
filtTagged = false |
| 56 |
+ } else if v != "false" {
|
|
| 57 |
+ return nil, fmt.Errorf("Invalid filter 'dangling=%s'", v)
|
|
| 56 | 58 |
} |
| 57 | 59 |
} |
| 58 | 60 |
} |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"strings" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
+ "github.com/docker/docker/pkg/integration/checker" |
|
| 10 | 11 |
"github.com/docker/docker/pkg/stringid" |
| 11 | 12 |
"github.com/go-check/check" |
| 12 | 13 |
) |
| ... | ... |
@@ -197,3 +198,9 @@ func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *check.C) {
|
| 197 | 197 |
c.Fatalf("expected 1 dangling image, got %d: %s", a, out)
|
| 198 | 198 |
} |
| 199 | 199 |
} |
| 200 |
+ |
|
| 201 |
+func (s *DockerSuite) TestImagesWithIncorrectFilter(c *check.C) {
|
|
| 202 |
+ out, _, err := dockerCmdWithError("images", "-f", "dangling=invalid")
|
|
| 203 |
+ c.Assert(err, check.NotNil) |
|
| 204 |
+ c.Assert(out, checker.Contains, "Invalid filter") |
|
| 205 |
+} |