1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

rename clusterProvider to cluster in router

Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
allencloud 2016-12-26 20:53:13 +08:00
parent 7d8a9b9234
commit 0238e9e92b
4 changed files with 20 additions and 20 deletions

View file

@ -7,16 +7,16 @@ import (
// networkRouter is a router to talk with the network controller
type networkRouter struct {
backend Backend
clusterProvider *cluster.Cluster
routes []router.Route
backend Backend
cluster *cluster.Cluster
routes []router.Route
}
// NewRouter initializes a new network router
func NewRouter(b Backend, c *cluster.Cluster) router.Router {
r := &networkRouter{
backend: b,
clusterProvider: c,
backend: b,
cluster: c,
}
r.initRoutes()
return r

View file

@ -27,7 +27,7 @@ func (n *networkRouter) getNetworksList(ctx context.Context, w http.ResponseWrit
list := []types.NetworkResource{}
if nr, err := n.clusterProvider.GetNetworks(); err == nil {
if nr, err := n.cluster.GetNetworks(); err == nil {
list = append(list, nr...)
}
@ -57,7 +57,7 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r
nw, err := n.backend.FindNetwork(vars["id"])
if err != nil {
if nr, err := n.clusterProvider.GetNetwork(vars["id"]); err == nil {
if nr, err := n.cluster.GetNetwork(vars["id"]); err == nil {
return httputils.WriteJSON(w, http.StatusOK, nr)
}
return err
@ -80,7 +80,7 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
return err
}
if nws, err := n.clusterProvider.GetNetworksByName(create.Name); err == nil && len(nws) > 0 {
if nws, err := n.cluster.GetNetworksByName(create.Name); err == nil && len(nws) > 0 {
return libnetwork.NetworkNameError(create.Name)
}
@ -89,7 +89,7 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
if _, ok := err.(libnetwork.ManagerRedirectError); !ok {
return err
}
id, err := n.clusterProvider.CreateNetwork(create)
id, err := n.cluster.CreateNetwork(create)
if err != nil {
return err
}
@ -137,8 +137,8 @@ func (n *networkRouter) deleteNetwork(ctx context.Context, w http.ResponseWriter
if err := httputils.ParseForm(r); err != nil {
return err
}
if _, err := n.clusterProvider.GetNetwork(vars["id"]); err == nil {
if err = n.clusterProvider.RemoveNetwork(vars["id"]); err != nil {
if _, err := n.cluster.GetNetwork(vars["id"]); err == nil {
if err = n.cluster.RemoveNetwork(vars["id"]); err != nil {
return err
}
w.WriteHeader(http.StatusNoContent)
@ -162,8 +162,8 @@ func (n *networkRouter) buildNetworkResource(nw libnetwork.Network) *types.Netwo
r.ID = nw.ID()
r.Created = info.Created()
r.Scope = info.Scope()
if n.clusterProvider.IsManager() {
if _, err := n.clusterProvider.GetNetwork(nw.Name()); err == nil {
if n.cluster.IsManager() {
if _, err := n.cluster.GetNetwork(nw.Name()); err == nil {
r.Scope = "swarm"
}
} else if info.Dynamic() {

View file

@ -8,16 +8,16 @@ import (
// systemRouter provides information about the Docker system overall.
// It gathers information about host, daemon and container events.
type systemRouter struct {
backend Backend
clusterProvider *cluster.Cluster
routes []router.Route
backend Backend
cluster *cluster.Cluster
routes []router.Route
}
// NewRouter initializes a new system router
func NewRouter(b Backend, c *cluster.Cluster) router.Router {
r := &systemRouter{
backend: b,
clusterProvider: c,
backend: b,
cluster: c,
}
r.routes = []router.Route{

View file

@ -35,8 +35,8 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
if err != nil {
return err
}
if s.clusterProvider != nil {
info.Swarm = s.clusterProvider.Info()
if s.cluster != nil {
info.Swarm = s.cluster.Info()
}
if versions.LessThan(httputils.VersionFromContext(ctx), "1.25") {