mirror of https://github.com/docker/docs.git
add support for pull and rmi
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
342ef1fff2
commit
7ad8a3705f
|
@ -18,7 +18,7 @@ GET "/containers/{name:.*}/attach/ws"
|
|||
|
||||
POST "/commit"
|
||||
POST "/build"
|
||||
POST "/images/create"
|
||||
POST "/images/create" (pull implemented)
|
||||
POST "/images/load"
|
||||
POST "/images/{name:.*}/push"
|
||||
POST "/images/{name:.*}/tag"
|
||||
|
|
30
api/api.go
30
api/api.go
|
@ -247,6 +247,34 @@ func deleteContainers(c *context, w http.ResponseWriter, r *http.Request) {
|
|||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// POST /images/create
|
||||
func postImagesCreate(c *context, w http.ResponseWriter, r *http.Request) {
|
||||
if err := r.ParseForm(); err != nil {
|
||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
wf := NewWriteFlusher(w)
|
||||
|
||||
if image := r.Form.Get("fromImage"); image != "" { //pull
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
|
||||
if tag := r.Form.Get("tag"); tag != "" {
|
||||
image += ":" + tag
|
||||
}
|
||||
begin := func(name string) {
|
||||
fmt.Fprintf(wf, "{%q:%q,%q:\"Pulling %s...\",%q:{}}", "id", name, "status", image, "progressDetail")
|
||||
}
|
||||
end := func(name string) {
|
||||
fmt.Fprintf(wf, "{%q:%q,%q:\"Pulling %s... : downloaded\",%q:{}}", "id", name, "status", image, "progressDetail")
|
||||
}
|
||||
c.cluster.Pull(image, begin, end)
|
||||
} else { //import
|
||||
httpError(w, "Not supported in clustering mode.", http.StatusNotImplemented)
|
||||
}
|
||||
}
|
||||
|
||||
// GET /events
|
||||
func getEvents(c *context, w http.ResponseWriter, r *http.Request) {
|
||||
c.eventsHandler.Add(r.RemoteAddr, w)
|
||||
|
@ -416,7 +444,7 @@ func createRouter(c *context, enableCors bool) *mux.Router {
|
|||
"/auth": proxyRandom,
|
||||
"/commit": notImplementedHandler,
|
||||
"/build": notImplementedHandler,
|
||||
"/images/create": notImplementedHandler,
|
||||
"/images/create": postImagesCreate,
|
||||
"/images/load": notImplementedHandler,
|
||||
"/images/{name:.*}/push": notImplementedHandler,
|
||||
"/images/{name:.*}/tag": notImplementedHandler,
|
||||
|
|
|
@ -11,5 +11,7 @@ type Cluster interface {
|
|||
Containers() []*Container
|
||||
Container(IdOrName string) *Container
|
||||
|
||||
Pull(name string, begin, end func(string))
|
||||
|
||||
Info() [][2]string
|
||||
}
|
||||
|
|
|
@ -186,6 +186,14 @@ func (c *Cluster) Image(IdOrName string) *cluster.Image {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) Pull(name string, begin, end func(string)) {
|
||||
for _, node := range c.nodes {
|
||||
begin(node.Name())
|
||||
node.Pull(name)
|
||||
end(node.Name())
|
||||
}
|
||||
}
|
||||
|
||||
// Containers returns all the containers in the cluster.
|
||||
func (c *Cluster) Containers() []*cluster.Container {
|
||||
c.RLock()
|
||||
|
|
Loading…
Reference in New Issue