mirror of
https://github.com/docker/docs.git
synced 2026-03-31 08:18:55 +07:00
fix image matching in push
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
@@ -58,20 +58,6 @@ func getVersion(c *context, w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(version)
|
||||
}
|
||||
|
||||
// GET /images/{name:.*}/get
|
||||
func getImage(c *context, w http.ResponseWriter, r *http.Request) {
|
||||
name := mux.Vars(r)["name"]
|
||||
|
||||
for _, image := range c.cluster.Images() {
|
||||
if len(strings.SplitN(name, ":", 2)) == 2 && image.Match(name, true) ||
|
||||
len(strings.SplitN(name, ":", 2)) == 1 && image.Match(name, false) {
|
||||
proxy(c.tlsConfig, image.Engine.Addr, w, r)
|
||||
return
|
||||
}
|
||||
}
|
||||
httpError(w, fmt.Sprintf("No such image: %s", name), http.StatusNotFound)
|
||||
}
|
||||
|
||||
// GET /images/get
|
||||
func getImages(c *context, w http.ResponseWriter, r *http.Request) {
|
||||
if err := r.ParseForm(); err != nil {
|
||||
@@ -566,6 +552,20 @@ func proxyImage(c *context, w http.ResponseWriter, r *http.Request) {
|
||||
httpError(w, fmt.Sprintf("No such image: %s", name), http.StatusNotFound)
|
||||
}
|
||||
|
||||
// Proxy a request to the right node
|
||||
func proxyImageTagOptional(c *context, w http.ResponseWriter, r *http.Request) {
|
||||
name := mux.Vars(r)["name"]
|
||||
|
||||
for _, image := range c.cluster.Images() {
|
||||
if len(strings.SplitN(name, ":", 2)) == 2 && image.Match(name, true) ||
|
||||
len(strings.SplitN(name, ":", 2)) == 1 && image.Match(name, false) {
|
||||
proxy(c.tlsConfig, image.Engine.Addr, w, r)
|
||||
return
|
||||
}
|
||||
}
|
||||
httpError(w, fmt.Sprintf("No such image: %s", name), http.StatusNotFound)
|
||||
}
|
||||
|
||||
// Proxy a request to the right node and force refresh
|
||||
func proxyImageAndForceRefresh(c *context, w http.ResponseWriter, r *http.Request) {
|
||||
name := mux.Vars(r)["name"]
|
||||
|
||||
@@ -30,7 +30,7 @@ var routes = map[string]map[string]handler{
|
||||
"/images/viz": notImplementedHandler,
|
||||
"/images/search": proxyRandom,
|
||||
"/images/get": getImages,
|
||||
"/images/{name:.*}/get": getImage,
|
||||
"/images/{name:.*}/get": proxyImageTagOptional,
|
||||
"/images/{name:.*}/history": proxyImage,
|
||||
"/images/{name:.*}/json": proxyImage,
|
||||
"/containers/ps": getContainersJSON,
|
||||
@@ -50,7 +50,7 @@ var routes = map[string]map[string]handler{
|
||||
"/build": proxyRandomAndForceRefresh,
|
||||
"/images/create": postImagesCreate,
|
||||
"/images/load": postImagesLoad,
|
||||
"/images/{name:.*}/push": proxyImage,
|
||||
"/images/{name:.*}/push": proxyImageTagOptional,
|
||||
"/images/{name:.*}/tag": proxyImageAndForceRefresh,
|
||||
"/containers/create": postContainersCreate,
|
||||
"/containers/{name:.*}/kill": proxyContainerAndForceRefresh,
|
||||
|
||||
Reference in New Issue
Block a user