5789ca7629
To bring the implementation inline with the specification, the names and structure of the API routes have been updated. The overloaded term "image" has been replaced with the term "manifest", which may also be known as "image manifest". The desire for the layer storage to be more of a general blob storage is reflected in moving from "layer" api prefixes to "blob". The "tarsum" path parameter has been replaced by a more general "digest" parameter and is no longer required to start uploads. Another set of changes will come along to support this change at the storage service layer.
64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
package registry
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gorilla/handlers"
|
|
)
|
|
|
|
// layerUploadDispatcher constructs and returns the layer upload handler for
|
|
// the given request context.
|
|
func layerUploadDispatcher(ctx *Context, r *http.Request) http.Handler {
|
|
layerUploadHandler := &layerUploadHandler{
|
|
Context: ctx,
|
|
TarSum: ctx.vars["tarsum"],
|
|
UUID: ctx.vars["uuid"],
|
|
}
|
|
|
|
layerUploadHandler.log = layerUploadHandler.log.WithField("tarsum", layerUploadHandler.TarSum)
|
|
|
|
if layerUploadHandler.UUID != "" {
|
|
layerUploadHandler.log = layerUploadHandler.log.WithField("uuid", layerUploadHandler.UUID)
|
|
}
|
|
|
|
return handlers.MethodHandler{
|
|
"POST": http.HandlerFunc(layerUploadHandler.StartLayerUpload),
|
|
"GET": http.HandlerFunc(layerUploadHandler.GetUploadStatus),
|
|
"HEAD": http.HandlerFunc(layerUploadHandler.GetUploadStatus),
|
|
"PUT": http.HandlerFunc(layerUploadHandler.PutLayerChunk),
|
|
"DELETE": http.HandlerFunc(layerUploadHandler.CancelLayerUpload),
|
|
}
|
|
}
|
|
|
|
// layerUploadHandler handles the http layer upload process.
|
|
type layerUploadHandler struct {
|
|
*Context
|
|
|
|
// TarSum is the unique identifier of the layer being uploaded.
|
|
TarSum string
|
|
|
|
// UUID identifies the upload instance for the current request.
|
|
UUID string
|
|
}
|
|
|
|
// StartLayerUpload begins the layer upload process and allocates a server-
|
|
// side upload session.
|
|
func (luh *layerUploadHandler) StartLayerUpload(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
// GetUploadStatus returns the status of a given upload, identified by uuid.
|
|
func (luh *layerUploadHandler) GetUploadStatus(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
// PutLayerChunk receives a layer chunk during the layer upload process,
|
|
// possible completing the upload with a checksum and length.
|
|
func (luh *layerUploadHandler) PutLayerChunk(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
// CancelLayerUpload cancels an in-progress upload of a layer.
|
|
func (luh *layerUploadHandler) CancelLayerUpload(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|