소스 검색

Merge pull request #36912 from vdemeester/api-no-daemon-dep

Remove daemon dependency on api packages
Brian Goff 7 년 전
부모
커밋
c028b6d089
4개의 변경된 파일21개의 추가작업 그리고 6개의 파일을 삭제
  1. 10 0
      api/server/router/network/backend.go
  2. 2 3
      api/server/router/network/network.go
  3. 7 0
      api/server/router/system/backend.go
  4. 2 3
      api/server/router/system/system.go

+ 10 - 0
api/server/router/network/backend.go

@@ -20,3 +20,13 @@ type Backend interface {
 	DeleteNetwork(networkID string) error
 	NetworksPrune(ctx context.Context, pruneFilters filters.Args) (*types.NetworksPruneReport, error)
 }
+
+// ClusterBackend is all the methods that need to be implemented
+// to provide cluster network specific functionality.
+type ClusterBackend interface {
+	GetNetworks() ([]types.NetworkResource, error)
+	GetNetwork(name string) (types.NetworkResource, error)
+	GetNetworksByName(name string) ([]types.NetworkResource, error)
+	CreateNetwork(nc types.NetworkCreateRequest) (string, error)
+	RemoveNetwork(name string) error
+}

+ 2 - 3
api/server/router/network/network.go

@@ -2,18 +2,17 @@ package network // import "github.com/docker/docker/api/server/router/network"
 
 import (
 	"github.com/docker/docker/api/server/router"
-	"github.com/docker/docker/daemon/cluster"
 )
 
 // networkRouter is a router to talk with the network controller
 type networkRouter struct {
 	backend Backend
-	cluster *cluster.Cluster
+	cluster ClusterBackend
 	routes  []router.Route
 }
 
 // NewRouter initializes a new network router
-func NewRouter(b Backend, c *cluster.Cluster) router.Router {
+func NewRouter(b Backend, c ClusterBackend) router.Router {
 	r := &networkRouter{
 		backend: b,
 		cluster: c,

+ 7 - 0
api/server/router/system/backend.go

@@ -6,6 +6,7 @@ import (
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types/events"
 	"github.com/docker/docker/api/types/filters"
+	"github.com/docker/docker/api/types/swarm"
 	"golang.org/x/net/context"
 )
 
@@ -19,3 +20,9 @@ type Backend interface {
 	UnsubscribeFromEvents(chan interface{})
 	AuthenticateToRegistry(ctx context.Context, authConfig *types.AuthConfig) (string, string, error)
 }
+
+// ClusterBackend is all the methods that need to be implemented
+// to provide cluster system specific functionality.
+type ClusterBackend interface {
+	Info() swarm.Info
+}

+ 2 - 3
api/server/router/system/system.go

@@ -3,20 +3,19 @@ package system // import "github.com/docker/docker/api/server/router/system"
 import (
 	"github.com/docker/docker/api/server/router"
 	"github.com/docker/docker/builder/fscache"
-	"github.com/docker/docker/daemon/cluster"
 )
 
 // systemRouter provides information about the Docker system overall.
 // It gathers information about host, daemon and container events.
 type systemRouter struct {
 	backend Backend
-	cluster *cluster.Cluster
+	cluster ClusterBackend
 	routes  []router.Route
 	builder *fscache.FSCache
 }
 
 // NewRouter initializes a new system router
-func NewRouter(b Backend, c *cluster.Cluster, fscache *fscache.FSCache) router.Router {
+func NewRouter(b Backend, c ClusterBackend, fscache *fscache.FSCache) router.Router {
 	r := &systemRouter{
 		backend: b,
 		cluster: c,