mirror of https://github.com/docker/docs.git
Merge pull request #249 from vieux/docker_images
Proposal: Simple docker images support
This commit is contained in:
commit
944ac685ef
|
@ -8,8 +8,6 @@ Here are the main differences:
|
||||||
####Some endpoints are not (yet) implemented
|
####Some endpoints are not (yet) implemented
|
||||||
|
|
||||||
```
|
```
|
||||||
GET "/images/json"
|
|
||||||
GET "/images/json"
|
|
||||||
GET "/images/get"
|
GET "/images/get"
|
||||||
GET "/images/{name:.*}/get"
|
GET "/images/{name:.*}/get"
|
||||||
GET "/images/{name:.*}/history"
|
GET "/images/{name:.*}/history"
|
||||||
|
|
42
api/api.go
42
api/api.go
|
@ -13,6 +13,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
dockerfilters "github.com/docker/docker/pkg/parsers/filters"
|
||||||
"github.com/docker/swarm/cluster"
|
"github.com/docker/swarm/cluster"
|
||||||
"github.com/docker/swarm/scheduler"
|
"github.com/docker/swarm/scheduler"
|
||||||
"github.com/docker/swarm/scheduler/filter"
|
"github.com/docker/swarm/scheduler/filter"
|
||||||
|
@ -79,6 +80,45 @@ func getVersion(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(version)
|
json.NewEncoder(w).Encode(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GET /images/json
|
||||||
|
func getImagesJSON(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
if err := r.ParseForm(); err != nil {
|
||||||
|
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
filters, err := dockerfilters.FromParam(r.Form.Get("filters"))
|
||||||
|
if err != nil {
|
||||||
|
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
accepteds, _ := filters["node"]
|
||||||
|
images := []*dockerclient.Image{}
|
||||||
|
|
||||||
|
for _, node := range c.cluster.Nodes() {
|
||||||
|
if len(accepteds) != 0 {
|
||||||
|
found := false
|
||||||
|
for _, accepted := range accepteds {
|
||||||
|
if accepted == node.Name || accepted == node.ID {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, image := range node.Images() {
|
||||||
|
images = append(images, image)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(images)
|
||||||
|
}
|
||||||
|
|
||||||
// GET /containers/ps
|
// GET /containers/ps
|
||||||
// GET /containers/json
|
// GET /containers/json
|
||||||
func getContainersJSON(c *context, w http.ResponseWriter, r *http.Request) {
|
func getContainersJSON(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -310,7 +350,7 @@ func createRouter(c *context, enableCors bool) *mux.Router {
|
||||||
"/events": getEvents,
|
"/events": getEvents,
|
||||||
"/info": getInfo,
|
"/info": getInfo,
|
||||||
"/version": getVersion,
|
"/version": getVersion,
|
||||||
"/images/json": notImplementedHandler,
|
"/images/json": getImagesJSON,
|
||||||
"/images/viz": notImplementedHandler,
|
"/images/viz": notImplementedHandler,
|
||||||
"/images/search": proxyRandom,
|
"/images/search": proxyRandom,
|
||||||
"/images/get": notImplementedHandler,
|
"/images/get": notImplementedHandler,
|
||||||
|
|
Loading…
Reference in New Issue