fix(ST1016): Use consistent method receiver names

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 70139978d3)
Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Matthieu MOREL
2025-04-27 11:11:55 +02:00
committed by Cory Snider
parent 4c5a99d08c
commit e53cf6bc02
14 changed files with 142 additions and 142 deletions

View File

@@ -25,15 +25,15 @@ func NewRouter(b Backend, d experimentalProvider) router.Router {
} }
// Routes returns the available routers to the build controller // Routes returns the available routers to the build controller
func (r *buildRouter) Routes() []router.Route { func (br *buildRouter) Routes() []router.Route {
return r.routes return br.routes
} }
func (r *buildRouter) initRoutes() { func (br *buildRouter) initRoutes() {
r.routes = []router.Route{ br.routes = []router.Route{
router.NewPostRoute("/build", r.postBuild), router.NewPostRoute("/build", br.postBuild),
router.NewPostRoute("/build/prune", r.postPrune), router.NewPostRoute("/build/prune", br.postPrune),
router.NewPostRoute("/build/cancel", r.postCancel), router.NewPostRoute("/build/cancel", br.postCancel),
} }
} }

View File

@@ -23,14 +23,14 @@ func NewRouter(b Backend, decoder httputils.ContainerDecoder) router.Router {
} }
// Routes returns the available routers to the checkpoint controller // Routes returns the available routers to the checkpoint controller
func (r *checkpointRouter) Routes() []router.Route { func (cr *checkpointRouter) Routes() []router.Route {
return r.routes return cr.routes
} }
func (r *checkpointRouter) initRoutes() { func (cr *checkpointRouter) initRoutes() {
r.routes = []router.Route{ cr.routes = []router.Route{
router.NewGetRoute("/containers/{name:.*}/checkpoints", r.getContainerCheckpoints, router.Experimental), router.NewGetRoute("/containers/{name:.*}/checkpoints", cr.getContainerCheckpoints, router.Experimental),
router.NewPostRoute("/containers/{name:.*}/checkpoints", r.postContainerCheckpoint, router.Experimental), router.NewPostRoute("/containers/{name:.*}/checkpoints", cr.postContainerCheckpoint, router.Experimental),
router.NewDeleteRoute("/containers/{name}/checkpoints/{checkpoint}", r.deleteContainerCheckpoint, router.Experimental), router.NewDeleteRoute("/containers/{name}/checkpoints/{checkpoint}", cr.deleteContainerCheckpoint, router.Experimental),
} }
} }

View File

@@ -8,7 +8,7 @@ import (
"github.com/docker/docker/api/types/checkpoint" "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 { if err := httputils.ParseForm(r); err != nil {
return err return err
} }
@@ -18,7 +18,7 @@ func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.R
return err return err
} }
err := s.backend.CheckpointCreate(vars["name"], options) err := cr.backend.CheckpointCreate(vars["name"], options)
if err != nil { if err != nil {
return err return err
} }
@@ -27,12 +27,12 @@ func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.R
return nil 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 { if err := httputils.ParseForm(r); err != nil {
return err 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"), CheckpointDir: r.Form.Get("dir"),
}) })
if err != nil { if err != nil {
@@ -42,12 +42,12 @@ func (s *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.R
return httputils.WriteJSON(w, http.StatusOK, checkpoints) 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 { if err := httputils.ParseForm(r); err != nil {
return err return err
} }
err := s.backend.CheckpointDelete(vars["name"], checkpoint.DeleteOptions{ err := cr.backend.CheckpointDelete(vars["name"], checkpoint.DeleteOptions{
CheckpointDir: r.Form.Get("dir"), CheckpointDir: r.Form.Get("dir"),
CheckpointID: vars["checkpoint"], CheckpointID: vars["checkpoint"],
}) })

View File

@@ -18,14 +18,14 @@ func NewRouter(backend Backend) router.Router {
} }
// Routes returns the available routes // Routes returns the available routes
func (r *distributionRouter) Routes() []router.Route { func (dr *distributionRouter) Routes() []router.Route {
return r.routes return dr.routes
} }
// initRoutes initializes the routes in the distribution router // initRoutes initializes the routes in the distribution router
func (r *distributionRouter) initRoutes() { func (dr *distributionRouter) initRoutes() {
r.routes = []router.Route{ dr.routes = []router.Route{
// GET // GET
router.NewGetRoute("/distribution/{name:.*}/json", r.getDistributionInfo), router.NewGetRoute("/distribution/{name:.*}/json", dr.getDistributionInfo),
} }
} }

View File

@@ -17,7 +17,7 @@ import (
"github.com/pkg/errors" "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 { if err := httputils.ParseForm(r); err != nil {
return err 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 // For a search it is not an error if no auth was given. Ignore invalid
// AuthConfig to increase compatibility with the existing API. // AuthConfig to increase compatibility with the existing API.
authConfig, _ := registry.DecodeAuthConfig(r.Header.Get(registry.AuthHeader)) 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 { if err != nil {
return err 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 // - https://github.com/moby/moby/blob/12c7411b6b7314bef130cd59f1c7384a7db06d0b/distribution/pull.go#L76-L152
var lastErr error var lastErr error
for _, repo := range repos { for _, repo := range repos {
distributionInspect, err := s.fetchManifest(ctx, repo, namedRef) distributionInspect, err := dr.fetchManifest(ctx, repo, namedRef)
if err != nil { if err != nil {
lastErr = err lastErr = err
continue continue
@@ -74,7 +74,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
return lastErr 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 var distributionInspect registry.DistributionInspect
if canonicalRef, ok := namedRef.(reference.Canonical); !ok { if canonicalRef, ok := namedRef.(reference.Canonical); !ok {
namedRef = reference.TagNameOnly(namedRef) namedRef = reference.TagNameOnly(namedRef)

View File

@@ -22,22 +22,22 @@ func NewRouter(b Backend, c ClusterBackend) router.Router {
} }
// Routes returns the available routes to the network controller // Routes returns the available routes to the network controller
func (r *networkRouter) Routes() []router.Route { func (n *networkRouter) Routes() []router.Route {
return r.routes return n.routes
} }
func (r *networkRouter) initRoutes() { func (n *networkRouter) initRoutes() {
r.routes = []router.Route{ n.routes = []router.Route{
// GET // GET
router.NewGetRoute("/networks", r.getNetworksList), router.NewGetRoute("/networks", n.getNetworksList),
router.NewGetRoute("/networks/", r.getNetworksList), router.NewGetRoute("/networks/", n.getNetworksList),
router.NewGetRoute("/networks/{id:.+}", r.getNetwork), router.NewGetRoute("/networks/{id:.+}", n.getNetwork),
// POST // POST
router.NewPostRoute("/networks/create", r.postNetworkCreate), router.NewPostRoute("/networks/create", n.postNetworkCreate),
router.NewPostRoute("/networks/{id:.*}/connect", r.postNetworkConnect), router.NewPostRoute("/networks/{id:.*}/connect", n.postNetworkConnect),
router.NewPostRoute("/networks/{id:.*}/disconnect", r.postNetworkDisconnect), router.NewPostRoute("/networks/{id:.*}/disconnect", n.postNetworkDisconnect),
router.NewPostRoute("/networks/prune", r.postNetworksPrune), router.NewPostRoute("/networks/prune", n.postNetworksPrune),
// DELETE // DELETE
router.NewDeleteRoute("/networks/{id:.*}", r.deleteNetwork), router.NewDeleteRoute("/networks/{id:.*}", n.deleteNetwork),
} }
} }

View File

@@ -18,22 +18,22 @@ func NewRouter(b Backend) router.Router {
} }
// Routes returns the available routers to the plugin controller // Routes returns the available routers to the plugin controller
func (r *pluginRouter) Routes() []router.Route { func (pr *pluginRouter) Routes() []router.Route {
return r.routes return pr.routes
} }
func (r *pluginRouter) initRoutes() { func (pr *pluginRouter) initRoutes() {
r.routes = []router.Route{ pr.routes = []router.Route{
router.NewGetRoute("/plugins", r.listPlugins), router.NewGetRoute("/plugins", pr.listPlugins),
router.NewGetRoute("/plugins/{name:.*}/json", r.inspectPlugin), router.NewGetRoute("/plugins/{name:.*}/json", pr.inspectPlugin),
router.NewGetRoute("/plugins/privileges", r.getPrivileges), router.NewGetRoute("/plugins/privileges", pr.getPrivileges),
router.NewDeleteRoute("/plugins/{name:.*}", r.removePlugin), router.NewDeleteRoute("/plugins/{name:.*}", pr.removePlugin),
router.NewPostRoute("/plugins/{name:.*}/enable", r.enablePlugin), router.NewPostRoute("/plugins/{name:.*}/enable", pr.enablePlugin),
router.NewPostRoute("/plugins/{name:.*}/disable", r.disablePlugin), router.NewPostRoute("/plugins/{name:.*}/disable", pr.disablePlugin),
router.NewPostRoute("/plugins/pull", r.pullPlugin), router.NewPostRoute("/plugins/pull", pr.pullPlugin),
router.NewPostRoute("/plugins/{name:.*}/push", r.pushPlugin), router.NewPostRoute("/plugins/{name:.*}/push", pr.pushPlugin),
router.NewPostRoute("/plugins/{name:.*}/upgrade", r.upgradePlugin), router.NewPostRoute("/plugins/{name:.*}/upgrade", pr.upgradePlugin),
router.NewPostRoute("/plugins/{name:.*}/set", r.setPlugin), router.NewPostRoute("/plugins/{name:.*}/set", pr.setPlugin),
router.NewPostRoute("/plugins/create", r.createPlugin), router.NewPostRoute("/plugins/create", pr.createPlugin),
} }
} }

View File

@@ -18,12 +18,12 @@ func NewRouter(b Backend) router.Router {
} }
// Routes returns the available routers to the session controller // Routes returns the available routers to the session controller
func (r *sessionRouter) Routes() []router.Route { func (sr *sessionRouter) Routes() []router.Route {
return r.routes return sr.routes
} }
func (r *sessionRouter) initRoutes() { func (sr *sessionRouter) initRoutes() {
r.routes = []router.Route{ sr.routes = []router.Route{
router.NewPostRoute("/session", r.startSession), router.NewPostRoute("/session", sr.startSession),
} }
} }

View File

@@ -20,21 +20,21 @@ func NewRouter(b Backend, cb ClusterBackend) router.Router {
} }
// Routes returns the available routes to the volumes controller // Routes returns the available routes to the volumes controller
func (r *volumeRouter) Routes() []router.Route { func (v *volumeRouter) Routes() []router.Route {
return r.routes return v.routes
} }
func (r *volumeRouter) initRoutes() { func (v *volumeRouter) initRoutes() {
r.routes = []router.Route{ v.routes = []router.Route{
// GET // GET
router.NewGetRoute("/volumes", r.getVolumesList), router.NewGetRoute("/volumes", v.getVolumesList),
router.NewGetRoute("/volumes/{name:.*}", r.getVolumeByName), router.NewGetRoute("/volumes/{name:.*}", v.getVolumeByName),
// POST // POST
router.NewPostRoute("/volumes/create", r.postVolumesCreate), router.NewPostRoute("/volumes/create", v.postVolumesCreate),
router.NewPostRoute("/volumes/prune", r.postVolumesPrune), router.NewPostRoute("/volumes/prune", v.postVolumesPrune),
// PUT // PUT
router.NewPutRoute("/volumes/{name:.*}", r.putVolumesUpdate), router.NewPutRoute("/volumes/{name:.*}", v.putVolumesUpdate),
// DELETE // DELETE
router.NewDeleteRoute("/volumes/{name:.*}", r.deleteVolumes), router.NewDeleteRoute("/volumes/{name:.*}", v.deleteVolumes),
} }
} }

View File

@@ -213,32 +213,32 @@ func ValidateFixedCIDRV6(val string) error {
// Validate performs a static validation on the network configuration parameters. // Validate performs a static validation on the network configuration parameters.
// Whatever can be assessed a priori before attempting any programming. // Whatever can be assessed a priori before attempting any programming.
func (c *networkConfiguration) Validate() error { func (ncfg *networkConfiguration) Validate() error {
if c.Mtu < 0 { if ncfg.Mtu < 0 {
return ErrInvalidMtu(c.Mtu) return ErrInvalidMtu(ncfg.Mtu)
} }
// If bridge v4 subnet is specified // 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 default gw is specified, it must be part of bridge subnet
if c.DefaultGatewayIPv4 != nil { if ncfg.DefaultGatewayIPv4 != nil {
if !c.AddressIPv4.Contains(c.DefaultGatewayIPv4) { if !ncfg.AddressIPv4.Contains(ncfg.DefaultGatewayIPv4) {
return &ErrInvalidGateway{} return &ErrInvalidGateway{}
} }
} }
} }
if c.EnableIPv6 { if ncfg.EnableIPv6 {
// If IPv6 is enabled, AddressIPv6 must have been configured. // 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")) 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. // 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 return err
} }
// If a default gw is specified, it must belong to AddressIPv6's subnet // 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{} return &ErrInvalidGateway{}
} }
} }
@@ -247,73 +247,73 @@ func (c *networkConfiguration) Validate() error {
} }
// Conflicts check if two NetworkConfiguration objects overlap // Conflicts check if two NetworkConfiguration objects overlap
func (c *networkConfiguration) Conflicts(o *networkConfiguration) error { func (ncfg *networkConfiguration) Conflicts(o *networkConfiguration) error {
if o == nil { if o == nil {
return errors.New("same configuration") return errors.New("same configuration")
} }
// Also empty, because only one network with empty name is allowed // 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") return errors.New("networks have same bridge name")
} }
// They must be in different subnets // They must be in different subnets
if (c.AddressIPv4 != nil && o.AddressIPv4 != nil) && if (ncfg.AddressIPv4 != nil && o.AddressIPv4 != nil) &&
(c.AddressIPv4.Contains(o.AddressIPv4.IP) || o.AddressIPv4.Contains(c.AddressIPv4.IP)) { (ncfg.AddressIPv4.Contains(o.AddressIPv4.IP) || o.AddressIPv4.Contains(ncfg.AddressIPv4.IP)) {
return errors.New("networks have overlapping IPv4") return errors.New("networks have overlapping IPv4")
} }
// They must be in different v6 subnets // They must be in different v6 subnets
if (c.AddressIPv6 != nil && o.AddressIPv6 != nil) && if (ncfg.AddressIPv6 != nil && o.AddressIPv6 != nil) &&
(c.AddressIPv6.Contains(o.AddressIPv6.IP) || o.AddressIPv6.Contains(c.AddressIPv6.IP)) { (ncfg.AddressIPv6.Contains(o.AddressIPv6.IP) || o.AddressIPv6.Contains(ncfg.AddressIPv6.IP)) {
return errors.New("networks have overlapping IPv6") return errors.New("networks have overlapping IPv6")
} }
return nil return nil
} }
func (c *networkConfiguration) fromLabels(labels map[string]string) error { func (ncfg *networkConfiguration) fromLabels(labels map[string]string) error {
var err error var err error
for label, value := range labels { for label, value := range labels {
switch label { switch label {
case BridgeName: case BridgeName:
c.BridgeName = value ncfg.BridgeName = value
case netlabel.DriverMTU: 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()) return parseErr(label, value, err.Error())
} }
case netlabel.EnableIPv6: 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()) return parseErr(label, value, err.Error())
} }
case EnableIPMasquerade: 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()) return parseErr(label, value, err.Error())
} }
case EnableICC: 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()) return parseErr(label, value, err.Error())
} }
case InhibitIPv4: 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()) return parseErr(label, value, err.Error())
} }
case DefaultBridge: 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()) return parseErr(label, value, err.Error())
} }
case DefaultBindingIP: 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") return parseErr(label, value, "nil ip")
} }
case netlabel.ContainerIfacePrefix: case netlabel.ContainerIfacePrefix:
c.ContainerIfacePrefix = value ncfg.ContainerIfacePrefix = value
case netlabel.HostIPv4: 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") return parseErr(label, value, "nil ip")
} }
case netlabel.HostIPv6: 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") return parseErr(label, value, "nil ip")
} }
} }
@@ -528,7 +528,7 @@ func parseNetworkGenericOptions(data interface{}) (*networkConfiguration, error)
return config, err 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 { if len(ipamV4Data) > 1 || len(ipamV6Data) > 1 {
return types.ForbiddenErrorf("bridge driver doesn't support multiple subnets") 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 { 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 { if gw, ok := ipamV4Data[0].AuxAddresses[DefaultGatewayV4AuxKey]; ok {
c.DefaultGatewayIPv4 = gw.IP ncfg.DefaultGatewayIPv4 = gw.IP
} }
if len(ipamV6Data) > 0 { if len(ipamV6Data) > 0 {
c.AddressIPv6 = ipamV6Data[0].Pool ncfg.AddressIPv6 = ipamV6Data[0].Pool
if ipamV6Data[0].Gateway != nil { 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 { if gw, ok := ipamV6Data[0].AuxAddresses[DefaultGatewayV6AuxKey]; ok {
c.DefaultGatewayIPv6 = gw.IP ncfg.DefaultGatewayIPv6 = gw.IP
} }
} }

View File

@@ -236,7 +236,7 @@ func (d *driver) parseNetworkOptions(id string, genericOptions map[string]string
return config, nil 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 { if len(ipamV6Data) > 0 {
return types.ForbiddenErrorf("windowsshim driver doesn't support v6 subnets") return types.ForbiddenErrorf("windowsshim driver doesn't support v6 subnets")
} }

View File

@@ -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() t.Helper()
for i := 0; i < 80; i++ { for i := 0; i < 80; i++ {
db.RLock() nDB.RLock()
_, ok := db.nodes[node] _, ok := nDB.nodes[node]
db.RUnlock() nDB.RUnlock()
if present && ok { if present && ok {
return return
} }
@@ -92,10 +92,10 @@ func (db *NetworkDB) verifyNodeExistence(t *testing.T, node string, present bool
time.Sleep(50 * time.Millisecond) 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() t.Helper()
const sleepInterval = 50 * time.Millisecond const sleepInterval = 50 * time.Millisecond
@@ -106,15 +106,15 @@ func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string
maxRetries = 80 maxRetries = 80
} }
for i := int64(0); i < maxRetries; i++ { for i := int64(0); i < maxRetries; i++ {
db.RLock() nDB.RLock()
nn, nnok := db.networks[node] nn, nnok := nDB.networks[node]
if nnok { if nnok {
n, ok := nn[id] n, ok := nn[id]
var leaving bool var leaving bool
if ok { if ok {
leaving = n.leaving leaving = n.leaving
} }
db.RUnlock() nDB.RUnlock()
if present && ok { if present && ok {
return return
} }
@@ -125,7 +125,7 @@ func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string
return return
} }
} else { } else {
db.RUnlock() nDB.RUnlock()
} }
time.Sleep(sleepInterval) time.Sleep(sleepInterval)
@@ -134,11 +134,11 @@ func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string
t.Error("Network existence verification failed") 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() t.Helper()
n := 80 n := 80
for i := 0; i < n; i++ { 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 { if present && err == nil && string(v) == value {
return return
} }
@@ -149,7 +149,7 @@ func (db *NetworkDB) verifyEntryExistence(t *testing.T, tname, nid, key, value s
time.Sleep(50 * time.Millisecond) 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) { 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) { func TestNetworkDBNodeJoinLeaveIteration(t *testing.T) {
dbs := createNetworkDBInstances(t, 2, "node", DefaultConfig()) dbs := createNetworkDBInstances(t, 2, "node", DefaultConfig())
dbChangeWitness := func(db *NetworkDB) func(network string, expectNodeCount int) { dbChangeWitness := func(nDB *NetworkDB) func(network string, expectNodeCount int) {
staleNetworkTime := db.networkClock.Time() staleNetworkTime := nDB.networkClock.Time()
return func(network string, expectNodeCount int) { return func(network string, expectNodeCount int) {
check := func(t poll.LogT) poll.Result { check := func(t poll.LogT) poll.Result {
networkTime := db.networkClock.Time() networkTime := nDB.networkClock.Time()
if networkTime <= staleNetworkTime { if networkTime <= staleNetworkTime {
return poll.Continue("network time is stale, no change registered yet.") return poll.Continue("network time is stale, no change registered yet.")
} }
count := -1 count := -1
db.Lock() nDB.Lock()
if nodes, ok := db.networkNodes[network]; ok { if nodes, ok := nDB.networkNodes[network]; ok {
count = len(nodes) count = len(nodes)
} }
db.Unlock() nDB.Unlock()
if count != expectNodeCount { if count != expectNodeCount {
return poll.Continue("current number of nodes is %d, expect %d.", count, expectNodeCount) return poll.Continue("current number of nodes is %d, expect %d.", count, expectNodeCount)
} }

View File

@@ -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 // <=> Returns true if a < b, false if a > b and advances to next level if a == b
// epi.prio <=> epj.prio # 2 < 1 // ep.prio <=> epj.prio # 2 < 1
// epi.gw <=> epj.gw # non-gw < gw // ep.gw <=> epj.gw # non-gw < gw
// epi.internal <=> epj.internal # non-internal < internal // ep.internal <=> epj.internal # non-internal < internal
// epi.joininfo <=> epj.joininfo # ipv6 < ipv4 // ep.joininfo <=> epj.joininfo # ipv6 < ipv4
// epi.name <=> epj.name # bar < foo // ep.name <=> epj.name # bar < foo
func (epi *Endpoint) Less(epj *Endpoint) bool { func (ep *Endpoint) Less(epj *Endpoint) bool {
var prioi, prioj int var prioi, prioj int
sbi, _ := epi.getSandbox() sbi, _ := ep.getSandbox()
sbj, _ := epj.getSandbox() sbj, _ := epj.getSandbox()
// Prio defaults to 0 // Prio defaults to 0
if sbi != nil { if sbi != nil {
prioi = sbi.epPriority[epi.ID()] prioi = sbi.epPriority[ep.ID()]
} }
if sbj != nil { if sbj != nil {
prioj = sbj.epPriority[epj.ID()] prioj = sbj.epPriority[epj.ID()]
@@ -715,24 +715,24 @@ func (epi *Endpoint) Less(epj *Endpoint) bool {
return prioi > prioj return prioi > prioj
} }
gwi := epi.endpointInGWNetwork() gwi := ep.endpointInGWNetwork()
gwj := epj.endpointInGWNetwork() gwj := epj.endpointInGWNetwork()
if gwi != gwj { if gwi != gwj {
return gwj return gwj
} }
inti := epi.getNetwork().Internal() inti := ep.getNetwork().Internal()
intj := epj.getNetwork().Internal() intj := epj.getNetwork().Internal()
if inti != intj { if inti != intj {
return intj return intj
} }
jii := 0 jii := 0
if epi.joinInfo != nil { if ep.joinInfo != nil {
if epi.joinInfo.gw != nil { if ep.joinInfo.gw != nil {
jii = jii + 1 jii = jii + 1
} }
if epi.joinInfo.gw6 != nil { if ep.joinInfo.gw6 != nil {
jii = jii + 2 jii = jii + 2
} }
} }
@@ -751,7 +751,7 @@ func (epi *Endpoint) Less(epj *Endpoint) bool {
return jii > jij return jii > jij
} }
return epi.network.Name() < epj.network.Name() return ep.network.Name() < epj.network.Name()
} }
func (sb *Sandbox) NdotsSet() bool { func (sb *Sandbox) NdotsSet() bool {

View File

@@ -10,10 +10,10 @@ type BuilderContext interface {
Remove(string) Remove(string)
} }
func (bc *tarSum) Remove(filename string) { func (ts *tarSum) Remove(filename string) {
for i, fis := range bc.sums { for i, fis := range ts.sums {
if fis.Name() == filename { 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 // Note, we don't just return because there could be
// more than one with this name // more than one with this name
} }