diff --git a/api/server/router/build/build.go b/api/server/router/build/build.go index 546901b750..43dac4cd80 100644 --- a/api/server/router/build/build.go +++ b/api/server/router/build/build.go @@ -25,15 +25,15 @@ func NewRouter(b Backend, d experimentalProvider) router.Router { } // Routes returns the available routers to the build controller -func (r *buildRouter) Routes() []router.Route { - return r.routes +func (br *buildRouter) Routes() []router.Route { + return br.routes } -func (r *buildRouter) initRoutes() { - r.routes = []router.Route{ - router.NewPostRoute("/build", r.postBuild), - router.NewPostRoute("/build/prune", r.postPrune), - router.NewPostRoute("/build/cancel", r.postCancel), +func (br *buildRouter) initRoutes() { + br.routes = []router.Route{ + router.NewPostRoute("/build", br.postBuild), + router.NewPostRoute("/build/prune", br.postPrune), + router.NewPostRoute("/build/cancel", br.postCancel), } } diff --git a/api/server/router/checkpoint/checkpoint.go b/api/server/router/checkpoint/checkpoint.go index 37bd0bdad8..681d14c2d5 100644 --- a/api/server/router/checkpoint/checkpoint.go +++ b/api/server/router/checkpoint/checkpoint.go @@ -23,14 +23,14 @@ func NewRouter(b Backend, decoder httputils.ContainerDecoder) router.Router { } // Routes returns the available routers to the checkpoint controller -func (r *checkpointRouter) Routes() []router.Route { - return r.routes +func (cr *checkpointRouter) Routes() []router.Route { + return cr.routes } -func (r *checkpointRouter) initRoutes() { - r.routes = []router.Route{ - router.NewGetRoute("/containers/{name:.*}/checkpoints", r.getContainerCheckpoints, router.Experimental), - router.NewPostRoute("/containers/{name:.*}/checkpoints", r.postContainerCheckpoint, router.Experimental), - router.NewDeleteRoute("/containers/{name}/checkpoints/{checkpoint}", r.deleteContainerCheckpoint, router.Experimental), +func (cr *checkpointRouter) initRoutes() { + cr.routes = []router.Route{ + router.NewGetRoute("/containers/{name:.*}/checkpoints", cr.getContainerCheckpoints, router.Experimental), + router.NewPostRoute("/containers/{name:.*}/checkpoints", cr.postContainerCheckpoint, router.Experimental), + router.NewDeleteRoute("/containers/{name}/checkpoints/{checkpoint}", cr.deleteContainerCheckpoint, router.Experimental), } } diff --git a/api/server/router/checkpoint/checkpoint_routes.go b/api/server/router/checkpoint/checkpoint_routes.go index 98d5826be2..fa19879d62 100644 --- a/api/server/router/checkpoint/checkpoint_routes.go +++ b/api/server/router/checkpoint/checkpoint_routes.go @@ -8,7 +8,7 @@ import ( "github.com/docker/docker/api/types/checkpoint" ) -func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func (cr *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := httputils.ParseForm(r); err != nil { return err } @@ -18,7 +18,7 @@ func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.R return err } - err := s.backend.CheckpointCreate(vars["name"], options) + err := cr.backend.CheckpointCreate(vars["name"], options) if err != nil { return err } @@ -27,12 +27,12 @@ func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.R return nil } -func (s *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func (cr *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := httputils.ParseForm(r); err != nil { return err } - checkpoints, err := s.backend.CheckpointList(vars["name"], checkpoint.ListOptions{ + checkpoints, err := cr.backend.CheckpointList(vars["name"], checkpoint.ListOptions{ CheckpointDir: r.Form.Get("dir"), }) if err != nil { @@ -42,12 +42,12 @@ func (s *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.R return httputils.WriteJSON(w, http.StatusOK, checkpoints) } -func (s *checkpointRouter) deleteContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func (cr *checkpointRouter) deleteContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := httputils.ParseForm(r); err != nil { return err } - err := s.backend.CheckpointDelete(vars["name"], checkpoint.DeleteOptions{ + err := cr.backend.CheckpointDelete(vars["name"], checkpoint.DeleteOptions{ CheckpointDir: r.Form.Get("dir"), CheckpointID: vars["checkpoint"], }) diff --git a/api/server/router/distribution/distribution.go b/api/server/router/distribution/distribution.go index 1e9e5ff836..6955f0cb02 100644 --- a/api/server/router/distribution/distribution.go +++ b/api/server/router/distribution/distribution.go @@ -18,14 +18,14 @@ func NewRouter(backend Backend) router.Router { } // Routes returns the available routes -func (r *distributionRouter) Routes() []router.Route { - return r.routes +func (dr *distributionRouter) Routes() []router.Route { + return dr.routes } // initRoutes initializes the routes in the distribution router -func (r *distributionRouter) initRoutes() { - r.routes = []router.Route{ +func (dr *distributionRouter) initRoutes() { + dr.routes = []router.Route{ // GET - router.NewGetRoute("/distribution/{name:.*}/json", r.getDistributionInfo), + router.NewGetRoute("/distribution/{name:.*}/json", dr.getDistributionInfo), } } diff --git a/api/server/router/distribution/distribution_routes.go b/api/server/router/distribution/distribution_routes.go index 9fb0f47a92..065453bf06 100644 --- a/api/server/router/distribution/distribution_routes.go +++ b/api/server/router/distribution/distribution_routes.go @@ -17,7 +17,7 @@ import ( "github.com/pkg/errors" ) -func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func (dr *distributionRouter) getDistributionInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := httputils.ParseForm(r); err != nil { return err } @@ -43,7 +43,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res // For a search it is not an error if no auth was given. Ignore invalid // AuthConfig to increase compatibility with the existing API. authConfig, _ := registry.DecodeAuthConfig(r.Header.Get(registry.AuthHeader)) - repos, err := s.backend.GetRepositories(ctx, namedRef, authConfig) + repos, err := dr.backend.GetRepositories(ctx, namedRef, authConfig) if err != nil { return err } @@ -64,7 +64,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res // - https://github.com/moby/moby/blob/12c7411b6b7314bef130cd59f1c7384a7db06d0b/distribution/pull.go#L76-L152 var lastErr error for _, repo := range repos { - distributionInspect, err := s.fetchManifest(ctx, repo, namedRef) + distributionInspect, err := dr.fetchManifest(ctx, repo, namedRef) if err != nil { lastErr = err continue @@ -74,7 +74,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res return lastErr } -func (s *distributionRouter) fetchManifest(ctx context.Context, distrepo distribution.Repository, namedRef reference.Named) (registry.DistributionInspect, error) { +func (dr *distributionRouter) fetchManifest(ctx context.Context, distrepo distribution.Repository, namedRef reference.Named) (registry.DistributionInspect, error) { var distributionInspect registry.DistributionInspect if canonicalRef, ok := namedRef.(reference.Canonical); !ok { namedRef = reference.TagNameOnly(namedRef) diff --git a/api/server/router/network/network.go b/api/server/router/network/network.go index d31883500b..27fa83b2b9 100644 --- a/api/server/router/network/network.go +++ b/api/server/router/network/network.go @@ -22,22 +22,22 @@ func NewRouter(b Backend, c ClusterBackend) router.Router { } // Routes returns the available routes to the network controller -func (r *networkRouter) Routes() []router.Route { - return r.routes +func (n *networkRouter) Routes() []router.Route { + return n.routes } -func (r *networkRouter) initRoutes() { - r.routes = []router.Route{ +func (n *networkRouter) initRoutes() { + n.routes = []router.Route{ // GET - router.NewGetRoute("/networks", r.getNetworksList), - router.NewGetRoute("/networks/", r.getNetworksList), - router.NewGetRoute("/networks/{id:.+}", r.getNetwork), + router.NewGetRoute("/networks", n.getNetworksList), + router.NewGetRoute("/networks/", n.getNetworksList), + router.NewGetRoute("/networks/{id:.+}", n.getNetwork), // POST - router.NewPostRoute("/networks/create", r.postNetworkCreate), - router.NewPostRoute("/networks/{id:.*}/connect", r.postNetworkConnect), - router.NewPostRoute("/networks/{id:.*}/disconnect", r.postNetworkDisconnect), - router.NewPostRoute("/networks/prune", r.postNetworksPrune), + router.NewPostRoute("/networks/create", n.postNetworkCreate), + router.NewPostRoute("/networks/{id:.*}/connect", n.postNetworkConnect), + router.NewPostRoute("/networks/{id:.*}/disconnect", n.postNetworkDisconnect), + router.NewPostRoute("/networks/prune", n.postNetworksPrune), // DELETE - router.NewDeleteRoute("/networks/{id:.*}", r.deleteNetwork), + router.NewDeleteRoute("/networks/{id:.*}", n.deleteNetwork), } } diff --git a/api/server/router/plugin/plugin.go b/api/server/router/plugin/plugin.go index 96190b3d03..4ddecd1141 100644 --- a/api/server/router/plugin/plugin.go +++ b/api/server/router/plugin/plugin.go @@ -18,22 +18,22 @@ func NewRouter(b Backend) router.Router { } // Routes returns the available routers to the plugin controller -func (r *pluginRouter) Routes() []router.Route { - return r.routes +func (pr *pluginRouter) Routes() []router.Route { + return pr.routes } -func (r *pluginRouter) initRoutes() { - r.routes = []router.Route{ - router.NewGetRoute("/plugins", r.listPlugins), - router.NewGetRoute("/plugins/{name:.*}/json", r.inspectPlugin), - router.NewGetRoute("/plugins/privileges", r.getPrivileges), - router.NewDeleteRoute("/plugins/{name:.*}", r.removePlugin), - router.NewPostRoute("/plugins/{name:.*}/enable", r.enablePlugin), - router.NewPostRoute("/plugins/{name:.*}/disable", r.disablePlugin), - router.NewPostRoute("/plugins/pull", r.pullPlugin), - router.NewPostRoute("/plugins/{name:.*}/push", r.pushPlugin), - router.NewPostRoute("/plugins/{name:.*}/upgrade", r.upgradePlugin), - router.NewPostRoute("/plugins/{name:.*}/set", r.setPlugin), - router.NewPostRoute("/plugins/create", r.createPlugin), +func (pr *pluginRouter) initRoutes() { + pr.routes = []router.Route{ + router.NewGetRoute("/plugins", pr.listPlugins), + router.NewGetRoute("/plugins/{name:.*}/json", pr.inspectPlugin), + router.NewGetRoute("/plugins/privileges", pr.getPrivileges), + router.NewDeleteRoute("/plugins/{name:.*}", pr.removePlugin), + router.NewPostRoute("/plugins/{name:.*}/enable", pr.enablePlugin), + router.NewPostRoute("/plugins/{name:.*}/disable", pr.disablePlugin), + router.NewPostRoute("/plugins/pull", pr.pullPlugin), + router.NewPostRoute("/plugins/{name:.*}/push", pr.pushPlugin), + router.NewPostRoute("/plugins/{name:.*}/upgrade", pr.upgradePlugin), + router.NewPostRoute("/plugins/{name:.*}/set", pr.setPlugin), + router.NewPostRoute("/plugins/create", pr.createPlugin), } } diff --git a/api/server/router/session/session.go b/api/server/router/session/session.go index 79ddc134e7..3d1a822dc4 100644 --- a/api/server/router/session/session.go +++ b/api/server/router/session/session.go @@ -18,12 +18,12 @@ func NewRouter(b Backend) router.Router { } // Routes returns the available routers to the session controller -func (r *sessionRouter) Routes() []router.Route { - return r.routes +func (sr *sessionRouter) Routes() []router.Route { + return sr.routes } -func (r *sessionRouter) initRoutes() { - r.routes = []router.Route{ - router.NewPostRoute("/session", r.startSession), +func (sr *sessionRouter) initRoutes() { + sr.routes = []router.Route{ + router.NewPostRoute("/session", sr.startSession), } } diff --git a/api/server/router/volume/volume.go b/api/server/router/volume/volume.go index cb6ee65b5f..4ce7d55419 100644 --- a/api/server/router/volume/volume.go +++ b/api/server/router/volume/volume.go @@ -20,21 +20,21 @@ func NewRouter(b Backend, cb ClusterBackend) router.Router { } // Routes returns the available routes to the volumes controller -func (r *volumeRouter) Routes() []router.Route { - return r.routes +func (v *volumeRouter) Routes() []router.Route { + return v.routes } -func (r *volumeRouter) initRoutes() { - r.routes = []router.Route{ +func (v *volumeRouter) initRoutes() { + v.routes = []router.Route{ // GET - router.NewGetRoute("/volumes", r.getVolumesList), - router.NewGetRoute("/volumes/{name:.*}", r.getVolumeByName), + router.NewGetRoute("/volumes", v.getVolumesList), + router.NewGetRoute("/volumes/{name:.*}", v.getVolumeByName), // POST - router.NewPostRoute("/volumes/create", r.postVolumesCreate), - router.NewPostRoute("/volumes/prune", r.postVolumesPrune), + router.NewPostRoute("/volumes/create", v.postVolumesCreate), + router.NewPostRoute("/volumes/prune", v.postVolumesPrune), // PUT - router.NewPutRoute("/volumes/{name:.*}", r.putVolumesUpdate), + router.NewPutRoute("/volumes/{name:.*}", v.putVolumesUpdate), // DELETE - router.NewDeleteRoute("/volumes/{name:.*}", r.deleteVolumes), + router.NewDeleteRoute("/volumes/{name:.*}", v.deleteVolumes), } } diff --git a/libnetwork/drivers/bridge/bridge_linux.go b/libnetwork/drivers/bridge/bridge_linux.go index 005c726f2d..e39ef0181c 100644 --- a/libnetwork/drivers/bridge/bridge_linux.go +++ b/libnetwork/drivers/bridge/bridge_linux.go @@ -213,32 +213,32 @@ func ValidateFixedCIDRV6(val string) error { // Validate performs a static validation on the network configuration parameters. // Whatever can be assessed a priori before attempting any programming. -func (c *networkConfiguration) Validate() error { - if c.Mtu < 0 { - return ErrInvalidMtu(c.Mtu) +func (ncfg *networkConfiguration) Validate() error { + if ncfg.Mtu < 0 { + return ErrInvalidMtu(ncfg.Mtu) } // If bridge v4 subnet is specified - if c.AddressIPv4 != nil { + if ncfg.AddressIPv4 != nil { // If default gw is specified, it must be part of bridge subnet - if c.DefaultGatewayIPv4 != nil { - if !c.AddressIPv4.Contains(c.DefaultGatewayIPv4) { + if ncfg.DefaultGatewayIPv4 != nil { + if !ncfg.AddressIPv4.Contains(ncfg.DefaultGatewayIPv4) { return &ErrInvalidGateway{} } } } - if c.EnableIPv6 { + if ncfg.EnableIPv6 { // If IPv6 is enabled, AddressIPv6 must have been configured. - if c.AddressIPv6 == nil { + if ncfg.AddressIPv6 == nil { return errdefs.System(errors.New("no IPv6 address was allocated for the bridge")) } // AddressIPv6 must be IPv6, and not overlap with the LL subnet prefix. - if err := validateIPv6Subnet(c.AddressIPv6); err != nil { + if err := validateIPv6Subnet(ncfg.AddressIPv6); err != nil { return err } // If a default gw is specified, it must belong to AddressIPv6's subnet - if c.DefaultGatewayIPv6 != nil && !c.AddressIPv6.Contains(c.DefaultGatewayIPv6) { + if ncfg.DefaultGatewayIPv6 != nil && !ncfg.AddressIPv6.Contains(ncfg.DefaultGatewayIPv6) { return &ErrInvalidGateway{} } } @@ -247,73 +247,73 @@ func (c *networkConfiguration) Validate() error { } // Conflicts check if two NetworkConfiguration objects overlap -func (c *networkConfiguration) Conflicts(o *networkConfiguration) error { +func (ncfg *networkConfiguration) Conflicts(o *networkConfiguration) error { if o == nil { return errors.New("same configuration") } // Also empty, because only one network with empty name is allowed - if c.BridgeName == o.BridgeName { + if ncfg.BridgeName == o.BridgeName { return errors.New("networks have same bridge name") } // They must be in different subnets - if (c.AddressIPv4 != nil && o.AddressIPv4 != nil) && - (c.AddressIPv4.Contains(o.AddressIPv4.IP) || o.AddressIPv4.Contains(c.AddressIPv4.IP)) { + if (ncfg.AddressIPv4 != nil && o.AddressIPv4 != nil) && + (ncfg.AddressIPv4.Contains(o.AddressIPv4.IP) || o.AddressIPv4.Contains(ncfg.AddressIPv4.IP)) { return errors.New("networks have overlapping IPv4") } // They must be in different v6 subnets - if (c.AddressIPv6 != nil && o.AddressIPv6 != nil) && - (c.AddressIPv6.Contains(o.AddressIPv6.IP) || o.AddressIPv6.Contains(c.AddressIPv6.IP)) { + if (ncfg.AddressIPv6 != nil && o.AddressIPv6 != nil) && + (ncfg.AddressIPv6.Contains(o.AddressIPv6.IP) || o.AddressIPv6.Contains(ncfg.AddressIPv6.IP)) { return errors.New("networks have overlapping IPv6") } return nil } -func (c *networkConfiguration) fromLabels(labels map[string]string) error { +func (ncfg *networkConfiguration) fromLabels(labels map[string]string) error { var err error for label, value := range labels { switch label { case BridgeName: - c.BridgeName = value + ncfg.BridgeName = value case netlabel.DriverMTU: - if c.Mtu, err = strconv.Atoi(value); err != nil { + if ncfg.Mtu, err = strconv.Atoi(value); err != nil { return parseErr(label, value, err.Error()) } case netlabel.EnableIPv6: - if c.EnableIPv6, err = strconv.ParseBool(value); err != nil { + if ncfg.EnableIPv6, err = strconv.ParseBool(value); err != nil { return parseErr(label, value, err.Error()) } case EnableIPMasquerade: - if c.EnableIPMasquerade, err = strconv.ParseBool(value); err != nil { + if ncfg.EnableIPMasquerade, err = strconv.ParseBool(value); err != nil { return parseErr(label, value, err.Error()) } case EnableICC: - if c.EnableICC, err = strconv.ParseBool(value); err != nil { + if ncfg.EnableICC, err = strconv.ParseBool(value); err != nil { return parseErr(label, value, err.Error()) } case InhibitIPv4: - if c.InhibitIPv4, err = strconv.ParseBool(value); err != nil { + if ncfg.InhibitIPv4, err = strconv.ParseBool(value); err != nil { return parseErr(label, value, err.Error()) } case DefaultBridge: - if c.DefaultBridge, err = strconv.ParseBool(value); err != nil { + if ncfg.DefaultBridge, err = strconv.ParseBool(value); err != nil { return parseErr(label, value, err.Error()) } case DefaultBindingIP: - if c.DefaultBindingIP = net.ParseIP(value); c.DefaultBindingIP == nil { + if ncfg.DefaultBindingIP = net.ParseIP(value); ncfg.DefaultBindingIP == nil { return parseErr(label, value, "nil ip") } case netlabel.ContainerIfacePrefix: - c.ContainerIfacePrefix = value + ncfg.ContainerIfacePrefix = value case netlabel.HostIPv4: - if c.HostIPv4 = net.ParseIP(value); c.HostIPv4 == nil { + if ncfg.HostIPv4 = net.ParseIP(value); ncfg.HostIPv4 == nil { return parseErr(label, value, "nil ip") } case netlabel.HostIPv6: - if c.HostIPv6 = net.ParseIP(value); c.HostIPv6 == nil { + if ncfg.HostIPv6 = net.ParseIP(value); ncfg.HostIPv6 == nil { return parseErr(label, value, "nil ip") } } @@ -528,7 +528,7 @@ func parseNetworkGenericOptions(data interface{}) (*networkConfiguration, error) return config, err } -func (c *networkConfiguration) processIPAM(id string, ipamV4Data, ipamV6Data []driverapi.IPAMData) error { +func (ncfg *networkConfiguration) processIPAM(id string, ipamV4Data, ipamV6Data []driverapi.IPAMData) error { if len(ipamV4Data) > 1 || len(ipamV6Data) > 1 { return types.ForbiddenErrorf("bridge driver doesn't support multiple subnets") } @@ -538,22 +538,22 @@ func (c *networkConfiguration) processIPAM(id string, ipamV4Data, ipamV6Data []d } if ipamV4Data[0].Gateway != nil { - c.AddressIPv4 = types.GetIPNetCopy(ipamV4Data[0].Gateway) + ncfg.AddressIPv4 = types.GetIPNetCopy(ipamV4Data[0].Gateway) } if gw, ok := ipamV4Data[0].AuxAddresses[DefaultGatewayV4AuxKey]; ok { - c.DefaultGatewayIPv4 = gw.IP + ncfg.DefaultGatewayIPv4 = gw.IP } if len(ipamV6Data) > 0 { - c.AddressIPv6 = ipamV6Data[0].Pool + ncfg.AddressIPv6 = ipamV6Data[0].Pool if ipamV6Data[0].Gateway != nil { - c.AddressIPv6 = types.GetIPNetCopy(ipamV6Data[0].Gateway) + ncfg.AddressIPv6 = types.GetIPNetCopy(ipamV6Data[0].Gateway) } if gw, ok := ipamV6Data[0].AuxAddresses[DefaultGatewayV6AuxKey]; ok { - c.DefaultGatewayIPv6 = gw.IP + ncfg.DefaultGatewayIPv6 = gw.IP } } diff --git a/libnetwork/drivers/windows/windows.go b/libnetwork/drivers/windows/windows.go index 32e8c67099..04244602a7 100644 --- a/libnetwork/drivers/windows/windows.go +++ b/libnetwork/drivers/windows/windows.go @@ -236,7 +236,7 @@ func (d *driver) parseNetworkOptions(id string, genericOptions map[string]string return config, nil } -func (c *networkConfiguration) processIPAM(id string, ipamV4Data, ipamV6Data []driverapi.IPAMData) error { +func (ncfg *networkConfiguration) processIPAM(id string, ipamV4Data, ipamV6Data []driverapi.IPAMData) error { if len(ipamV6Data) > 0 { return types.ForbiddenErrorf("windowsshim driver doesn't support v6 subnets") } diff --git a/libnetwork/networkdb/networkdb_test.go b/libnetwork/networkdb/networkdb_test.go index 7ed5f36232..a6f6254f28 100644 --- a/libnetwork/networkdb/networkdb_test.go +++ b/libnetwork/networkdb/networkdb_test.go @@ -75,12 +75,12 @@ func closeNetworkDBInstances(t *testing.T, dbs []*NetworkDB) { } } -func (db *NetworkDB) verifyNodeExistence(t *testing.T, node string, present bool) { +func (nDB *NetworkDB) verifyNodeExistence(t *testing.T, node string, present bool) { t.Helper() for i := 0; i < 80; i++ { - db.RLock() - _, ok := db.nodes[node] - db.RUnlock() + nDB.RLock() + _, ok := nDB.nodes[node] + nDB.RUnlock() if present && ok { return } @@ -92,10 +92,10 @@ func (db *NetworkDB) verifyNodeExistence(t *testing.T, node string, present bool time.Sleep(50 * time.Millisecond) } - t.Errorf("%v(%v): Node existence verification for node %s failed", db.config.Hostname, db.config.NodeID, node) + t.Errorf("%v(%v): Node existence verification for node %s failed", nDB.config.Hostname, nDB.config.NodeID, node) } -func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string, present bool) { +func (nDB *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string, present bool) { t.Helper() const sleepInterval = 50 * time.Millisecond @@ -106,15 +106,15 @@ func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string maxRetries = 80 } for i := int64(0); i < maxRetries; i++ { - db.RLock() - nn, nnok := db.networks[node] + nDB.RLock() + nn, nnok := nDB.networks[node] if nnok { n, ok := nn[id] var leaving bool if ok { leaving = n.leaving } - db.RUnlock() + nDB.RUnlock() if present && ok { return } @@ -125,7 +125,7 @@ func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string return } } else { - db.RUnlock() + nDB.RUnlock() } time.Sleep(sleepInterval) @@ -134,11 +134,11 @@ func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string t.Error("Network existence verification failed") } -func (db *NetworkDB) verifyEntryExistence(t *testing.T, tname, nid, key, value string, present bool) { +func (nDB *NetworkDB) verifyEntryExistence(t *testing.T, tname, nid, key, value string, present bool) { t.Helper() n := 80 for i := 0; i < n; i++ { - v, err := db.GetEntry(tname, nid, key) + v, err := nDB.GetEntry(tname, nid, key) if present && err == nil && string(v) == value { return } @@ -149,7 +149,7 @@ func (db *NetworkDB) verifyEntryExistence(t *testing.T, tname, nid, key, value s time.Sleep(50 * time.Millisecond) } - t.Errorf("Entry existence verification test failed for %v(%v)", db.config.Hostname, db.config.NodeID) + t.Errorf("Entry existence verification test failed for %v(%v)", nDB.config.Hostname, nDB.config.NodeID) } func testWatch(t *testing.T, ch chan events.Event, ev interface{}, tname, nid, key, value string) { @@ -496,20 +496,20 @@ func TestNetworkDBCRUDMediumCluster(t *testing.T) { func TestNetworkDBNodeJoinLeaveIteration(t *testing.T) { dbs := createNetworkDBInstances(t, 2, "node", DefaultConfig()) - dbChangeWitness := func(db *NetworkDB) func(network string, expectNodeCount int) { - staleNetworkTime := db.networkClock.Time() + dbChangeWitness := func(nDB *NetworkDB) func(network string, expectNodeCount int) { + staleNetworkTime := nDB.networkClock.Time() return func(network string, expectNodeCount int) { check := func(t poll.LogT) poll.Result { - networkTime := db.networkClock.Time() + networkTime := nDB.networkClock.Time() if networkTime <= staleNetworkTime { return poll.Continue("network time is stale, no change registered yet.") } count := -1 - db.Lock() - if nodes, ok := db.networkNodes[network]; ok { + nDB.Lock() + if nodes, ok := nDB.networkNodes[network]; ok { count = len(nodes) } - db.Unlock() + nDB.Unlock() if count != expectNodeCount { return poll.Continue("current number of nodes is %d, expect %d.", count, expectNodeCount) } diff --git a/libnetwork/sandbox.go b/libnetwork/sandbox.go index c7e625a6bd..e6aa8f5861 100644 --- a/libnetwork/sandbox.go +++ b/libnetwork/sandbox.go @@ -692,20 +692,20 @@ func (sb *Sandbox) joinLeaveEnd() { } // <=> Returns true if a < b, false if a > b and advances to next level if a == b -// epi.prio <=> epj.prio # 2 < 1 -// epi.gw <=> epj.gw # non-gw < gw -// epi.internal <=> epj.internal # non-internal < internal -// epi.joininfo <=> epj.joininfo # ipv6 < ipv4 -// epi.name <=> epj.name # bar < foo -func (epi *Endpoint) Less(epj *Endpoint) bool { +// ep.prio <=> epj.prio # 2 < 1 +// ep.gw <=> epj.gw # non-gw < gw +// ep.internal <=> epj.internal # non-internal < internal +// ep.joininfo <=> epj.joininfo # ipv6 < ipv4 +// ep.name <=> epj.name # bar < foo +func (ep *Endpoint) Less(epj *Endpoint) bool { var prioi, prioj int - sbi, _ := epi.getSandbox() + sbi, _ := ep.getSandbox() sbj, _ := epj.getSandbox() // Prio defaults to 0 if sbi != nil { - prioi = sbi.epPriority[epi.ID()] + prioi = sbi.epPriority[ep.ID()] } if sbj != nil { prioj = sbj.epPriority[epj.ID()] @@ -715,24 +715,24 @@ func (epi *Endpoint) Less(epj *Endpoint) bool { return prioi > prioj } - gwi := epi.endpointInGWNetwork() + gwi := ep.endpointInGWNetwork() gwj := epj.endpointInGWNetwork() if gwi != gwj { return gwj } - inti := epi.getNetwork().Internal() + inti := ep.getNetwork().Internal() intj := epj.getNetwork().Internal() if inti != intj { return intj } jii := 0 - if epi.joinInfo != nil { - if epi.joinInfo.gw != nil { + if ep.joinInfo != nil { + if ep.joinInfo.gw != nil { jii = jii + 1 } - if epi.joinInfo.gw6 != nil { + if ep.joinInfo.gw6 != nil { jii = jii + 2 } } @@ -751,7 +751,7 @@ func (epi *Endpoint) Less(epj *Endpoint) bool { return jii > jij } - return epi.network.Name() < epj.network.Name() + return ep.network.Name() < epj.network.Name() } func (sb *Sandbox) NdotsSet() bool { diff --git a/pkg/tarsum/builder_context.go b/pkg/tarsum/builder_context.go index bc7d84df4e..376194750f 100644 --- a/pkg/tarsum/builder_context.go +++ b/pkg/tarsum/builder_context.go @@ -10,10 +10,10 @@ type BuilderContext interface { Remove(string) } -func (bc *tarSum) Remove(filename string) { - for i, fis := range bc.sums { +func (ts *tarSum) Remove(filename string) { + for i, fis := range ts.sums { if fis.Name() == filename { - bc.sums = append(bc.sums[:i], bc.sums[i+1:]...) + ts.sums = append(ts.sums[:i], ts.sums[i+1:]...) // Note, we don't just return because there could be // more than one with this name }