forked from microsoft/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request moby#19772 from calavera/decouple-server-routers
[Carry 19133] Decouple server routers from the daemon package.
- Loading branch information
Showing
22 changed files
with
382 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package image | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/docker/docker/reference" | ||
"github.com/docker/engine-api/types" | ||
"github.com/docker/engine-api/types/container" | ||
"github.com/docker/engine-api/types/registry" | ||
) | ||
|
||
// Backend is all the methods that need to be implemented | ||
// to provide image specific functionality. | ||
type Backend interface { | ||
containerBackend | ||
imageBackend | ||
importExportBackend | ||
registryBackend | ||
} | ||
|
||
type containerBackend interface { | ||
Commit(name string, config *types.ContainerCommitConfig) (imageID string, err error) | ||
Exists(containerName string) bool | ||
} | ||
|
||
type imageBackend interface { | ||
ImageDelete(imageRef string, force, prune bool) ([]types.ImageDelete, error) | ||
ImageHistory(imageName string) ([]*types.ImageHistory, error) | ||
Images(filterArgs string, filter string, all bool) ([]*types.Image, error) | ||
LookupImage(name string) (*types.ImageInspect, error) | ||
TagImage(newTag reference.Named, imageName string) error | ||
} | ||
|
||
type importExportBackend interface { | ||
LoadImage(inTar io.ReadCloser, outStream io.Writer, quiet bool) error | ||
ImportImage(src string, newRef reference.Named, msg string, inConfig io.ReadCloser, outStream io.Writer, config *container.Config) error | ||
ExportImage(names []string, outStream io.Writer) error | ||
} | ||
|
||
type registryBackend interface { | ||
PullImage(ref reference.Named, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error | ||
PushImage(ref reference.Named, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error | ||
SearchRegistryForImages(term string, authConfig *types.AuthConfig, metaHeaders map[string][]string) (*registry.SearchResults, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package image | ||
|
||
import "github.com/docker/docker/api/server/router" | ||
|
||
// imageRouter is a router to talk with the image controller | ||
type imageRouter struct { | ||
daemon Backend | ||
routes []router.Route | ||
} | ||
|
||
// NewRouter initializes a new image router | ||
func NewRouter(daemon Backend) router.Router { | ||
r := &imageRouter{ | ||
daemon: daemon, | ||
} | ||
r.initRoutes() | ||
return r | ||
} | ||
|
||
// Routes returns the available routes to the image controller | ||
func (r *imageRouter) Routes() []router.Route { | ||
return r.routes | ||
} | ||
|
||
// initRoutes initializes the routes in the image router | ||
func (r *imageRouter) initRoutes() { | ||
r.routes = []router.Route{ | ||
// GET | ||
router.NewGetRoute("/images/json", r.getImagesJSON), | ||
router.NewGetRoute("/images/search", r.getImagesSearch), | ||
router.NewGetRoute("/images/get", r.getImagesGet), | ||
router.NewGetRoute("/images/{name:.*}/get", r.getImagesGet), | ||
router.NewGetRoute("/images/{name:.*}/history", r.getImagesHistory), | ||
router.NewGetRoute("/images/{name:.*}/json", r.getImagesByName), | ||
// POST | ||
router.NewPostRoute("/commit", r.postCommit), | ||
router.NewPostRoute("/images/create", r.postImagesCreate), | ||
router.NewPostRoute("/images/load", r.postImagesLoad), | ||
router.NewPostRoute("/images/{name:.*}/push", r.postImagesPush), | ||
router.NewPostRoute("/images/{name:.*}/tag", r.postImagesTag), | ||
// DELETE | ||
router.NewDeleteRoute("/images/{name:.*}", r.deleteImages), | ||
} | ||
} |
Oops, something went wrong.