func queryContainers(queryStr, endpoint string) { matcher, err := query.Parse(queryStr, conFields) if err != nil { fail("Invalid query: %v", err) } client := NewDocker(endpoint) containers, err := client.ListContainers(docker.ListContainersOptions{All: true}) if err != nil { fail("Error while listing containers: %v", err) } for _, container := range containers { if matcher.Match(wrapContainer(client, container)) { fmt.Printf("%s\n", container.ID) } } }
func queryImages(queryStr, endpoint string) { matcher, err := query.Parse(queryStr, imgFields) if err != nil { fail("Invalid query: %v", err) } client := NewDocker(endpoint) images, err := client.ListImages(docker.ListImagesOptions{All: false}) if err != nil { fail("Error while listing containers: %v", err) } for _, image := range images { if matcher.Match(wrapImage(client, image)) { fmt.Printf("%s\n", image.ID) } } }