2014-11-11 03:57:38 +01:00
|
|
|
package registry
|
|
|
|
|
2014-12-10 06:25:54 +01:00
|
|
|
import (
|
|
|
|
"github.com/Sirupsen/logrus"
|
2014-12-24 01:01:38 +01:00
|
|
|
"github.com/docker/distribution/api/v2"
|
2015-01-17 03:32:27 +01:00
|
|
|
"github.com/docker/distribution/storage"
|
2014-12-10 06:25:54 +01:00
|
|
|
)
|
2014-11-11 03:57:38 +01:00
|
|
|
|
|
|
|
// Context should contain the request specific context for use in across
|
|
|
|
// handlers. Resources that don't need to be shared across handlers should not
|
|
|
|
// be on this object.
|
|
|
|
type Context struct {
|
|
|
|
// App points to the application structure that created this context.
|
|
|
|
*App
|
|
|
|
|
2015-01-17 03:32:27 +01:00
|
|
|
// Repository is the repository for the current request. All requests
|
|
|
|
// should be scoped to a single repository. This field may be nil.
|
|
|
|
Repository storage.Repository
|
2014-11-11 03:57:38 +01:00
|
|
|
|
|
|
|
// Errors is a collection of errors encountered during the request to be
|
|
|
|
// returned to the client API. If errors are added to the collection, the
|
|
|
|
// handler *must not* start the response via http.ResponseWriter.
|
2014-12-12 07:24:25 +01:00
|
|
|
Errors v2.Errors
|
2014-11-11 03:57:38 +01:00
|
|
|
|
|
|
|
// vars contains the extracted gorilla/mux variables that can be used for
|
|
|
|
// assignment.
|
|
|
|
vars map[string]string
|
|
|
|
|
|
|
|
// log provides a context specific logger.
|
|
|
|
log *logrus.Entry
|
Initial implementation of Manifest HTTP API
Push, pull and delete of manifest files in the registry have been implemented
on top of the storage services. Basic workflows, including reporting of missing
manifests are tested, including various proposed response codes. Common testing
functionality has been collected into shared methods. A test suite may be
emerging but it might better to capture more edge cases (such as resumable
upload, range requests, etc.) before we commit to a full approach.
To support clearer test cases and simpler handler methods, an application aware
urlBuilder has been added. We may want to export the functionality for use in
the client, which could allow us to abstract away from gorilla/mux.
A few error codes have been added to fill in error conditions missing from the
proposal. Some use cases have identified some problems with the approach to
error reporting that requires more work to reconcile. To resolve this, the
mapping of Go errors into error types needs to pulled out of the handlers and
into the application. We also need to move to type-based errors, with rich
information, rather than value-based errors. ErrorHandlers will probably
replace the http.Handlers to make this work correctly.
Unrelated to the above, the "length" parameter has been migrated to "size" for
completing layer uploads. This change should have gone out before but these
diffs ending up being coupled with the parameter name change due to updates to
the layer unit tests.
2014-11-26 21:16:58 +01:00
|
|
|
|
2014-12-12 07:24:25 +01:00
|
|
|
urlBuilder *v2.URLBuilder
|
2014-11-11 03:57:38 +01:00
|
|
|
}
|