libnetwork: fix empty-lines (revive)

libnetwork/etchosts/etchosts_test.go:167:54: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/osl/route_linux.go:185:74: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/osl/sandbox_linux_test.go:323:36: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/bitseq/sequence.go:412:48: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/datastore/datastore_test.go:67:46: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/datastore/mock_store.go:34:60: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/firewalld.go:202:44: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/firewalld_test.go:76:36: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/iptables.go:256:67: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/iptables.go:303:128: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/networkdb/cluster.go:183:72: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/ipams/null/null_test.go:44:38: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/macvlan/macvlan_store.go:45:52: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/ipam/allocator_test.go:1058:39: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/bridge/port_mapping.go:88:111: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/bridge/link.go:26:90: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/bridge/setup_ipv6_test.go:17:34: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/bridge/setup_ip_tables.go:392:4: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/bridge/bridge.go:804:50: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/ov_serf.go:183:29: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/ov_utils.go:81:64: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:172:67: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:209:67: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:344:89: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:436:63: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/overlay.go:183:36: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/encryption.go:69:28: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/overlay/ov_network.go:563:81: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/default_gateway.go:32:43: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/errors_test.go:9:40: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/service_common.go:184:64: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/endpoint.go:161:55: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/store.go:320:33: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/store_linux_test.go:11:38: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/sandbox.go:571:36: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/service_common.go:317:246: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/endpoint.go:550:17: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/sandbox_dns_unix.go:213:106: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/controller.go:676:85: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/agent.go:876:60: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/resolver.go:324:69: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/network.go:1153:92: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/network.go:1955:67: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/network.go:2235:9: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/libnetwork_internal_test.go:336:26: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/resolver_test.go:76:35: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/libnetwork_test.go:303:38: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/libnetwork_test.go:985:46: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/ipam/allocator_test.go:1263:37: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/errors_test.go:9:40: empty-lines: extra empty line at the end of a block (revive)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-09-23 22:25:41 +02:00
parent 267108e113
commit cd381aea56
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
40 changed files with 11 additions and 72 deletions

View file

@ -895,7 +895,6 @@ func (c *controller) handleNodeTableEvent(ev events.Event) {
return
}
c.processNodeDiscovery([]net.IP{nodeAddr.Addr}, isAdd)
}
func (c *controller) handleEpTableEvent(ev events.Event) {

View file

@ -410,7 +410,6 @@ func (h *Handle) Destroy() error {
// ToByteArray converts this handle's data into a byte array
func (h *Handle) ToByteArray() ([]byte, error) {
h.Lock()
defer h.Unlock()
ba := make([]byte, 16)

View file

@ -675,7 +675,6 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
if network.scope == datastore.LocalScope && cap.DataScope == datastore.GlobalScope {
return nil, types.ForbiddenErrorf("cannot downgrade network scope for %s networks", networkType)
}
if network.ingress && cap.DataScope != datastore.GlobalScope {
return nil, types.ForbiddenErrorf("Ingress network can only be global scope network")

View file

@ -108,7 +108,6 @@ func TestAtomicKVObjectFlatKey(t *testing.T) {
if err != nil {
t.Fatal(err)
}
}
// dummy data used to test the datastore

View file

@ -37,7 +37,6 @@ func (s *MockStore) Get(key string) (*store.KVPair, error) {
return nil, nil
}
return &store.KVPair{Value: mData.Data, LastIndex: mData.Index}, nil
}
// Put a value at "key"

View file

@ -30,7 +30,6 @@ var procGwNetwork = make(chan (bool), 1)
*/
func (sb *sandbox) setupDefaultGW() error {
// check if the container already has a GW endpoint
if ep := sb.getEndpointInGWNetwork(); ep != nil {
return nil

View file

@ -802,7 +802,6 @@ func (d *driver) createNetwork(config *networkConfiguration) (err error) {
}
func (d *driver) DeleteNetwork(nid string) error {
d.configNetwork.Lock()
defer d.configNetwork.Unlock()

View file

@ -30,7 +30,6 @@ func newLink(parentIP, childIP string, ports []types.TransportPort, bridge strin
ports: ports,
bridge: bridge,
}
}
func (l *link) Enable() error {

View file

@ -86,7 +86,7 @@ func (n *bridgeNetwork) allocatePortsInternal(bindings []types.PortBinding, cont
// validatePortBindingIPv4 validates the port binding, populates the missing Host IP field and returns true
// if this is a valid IPv4 binding, else returns false
func (n *bridgeNetwork) validatePortBindingIPv4(bnd *types.PortBinding, containerIPv4, defHostIP net.IP) bool {
//Return early if there is a valid Host IP, but its not a IPv4 address
// Return early if there is a valid Host IP, but its not a IPv4 address
if len(bnd.HostIP) > 0 && bnd.HostIP.To4() == nil {
return false
}
@ -100,7 +100,6 @@ func (n *bridgeNetwork) validatePortBindingIPv4(bnd *types.PortBinding, containe
}
bnd.IP = containerIPv4
return true
}
// validatePortBindingIPv6 validates the port binding, populates the missing Host IP field and returns true

View file

@ -390,7 +390,6 @@ func removeIPChains(version iptables.IPVersion) {
{Name: IsolationChain2, Table: iptables.Filter, IPTable: ipt},
{Name: oldIsolationChain, Table: iptables.Filter, IPTable: ipt},
} {
if err := chainInfo.Remove(); err != nil {
logrus.Warnf("Failed to remove existing iptables entries in table %s chain %s : %v", chainInfo.Table, chainInfo.Name, err)
}

View file

@ -53,7 +53,6 @@ func TestSetupIPv6(t *testing.T) {
if !found {
t.Fatalf("Bridge device does not have requested IPv6 address %v", bridgeIPv6)
}
}
func TestSetupGatewayIPv6(t *testing.T) {

View file

@ -61,7 +61,6 @@ func (d *driver) initStore(option map[string]interface{}) error {
if err != nil {
return err
}
}
return nil

View file

@ -10,11 +10,10 @@ import (
"fmt"
"hash/fnv"
"net"
"strconv"
"sync"
"syscall"
"strconv"
"github.com/docker/docker/libnetwork/drivers/overlay/overlayutils"
"github.com/docker/docker/libnetwork/iptables"
"github.com/docker/docker/libnetwork/ns"
@ -76,7 +75,6 @@ func (e *encrMap) String() string {
b.WriteString(",")
}
b.WriteString("]")
}
return b.String()
}

View file

@ -561,7 +561,6 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro
}
func (n *network) setupSubnetSandbox(s *subnet, brName, vxlanName string) error {
if hostMode {
// Try to delete stale bridge interface if it exists
if err := deleteInterface(brName); err != nil {
@ -1076,7 +1075,7 @@ func (n *network) releaseVxlanID() ([]uint32, error) {
}
func (n *network) obtainVxlanID(s *subnet) error {
//return if the subnet already has a vxlan id assigned
// return if the subnet already has a vxlan id assigned
if n.vxlanID(s) != 0 {
return nil
}

View file

@ -179,9 +179,7 @@ func (d *driver) resolvePeer(nid string, peerIP net.IP) (net.HardwareAddr, net.I
}
}
func (d *driver) startSerfLoop(eventCh chan serf.Event, notifyCh chan ovNotify,
exitCh chan chan struct{}) {
func (d *driver) startSerfLoop(eventCh chan serf.Event, notifyCh chan ovNotify, exitCh chan chan struct{}) {
for {
select {
case notify, ok := <-notifyCh:

View file

@ -106,7 +106,6 @@ func deleteInterfaceBySubnet(brPrefix string, s *subnet) error {
}
}
return nil
}
func deleteInterface(name string) error {

View file

@ -181,7 +181,6 @@ func Fini(drv driverapi.Driver) {
}
func (d *driver) configure() error {
// Apply OS specific kernel configs if needed
d.initOS.Do(applyOStweaks)

View file

@ -168,9 +168,7 @@ func (d *driver) peerDbSearch(nid string, peerIP net.IP) (*peerKey, *peerEntry,
return pKeyMatched, pEntryMatched, nil
}
func (d *driver) peerDbAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerMac net.HardwareAddr, vtep net.IP, isLocal bool) (bool, int) {
func (d *driver) peerDbAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP, isLocal bool) (bool, int) {
d.peerDb.Lock()
pMap, ok := d.peerDb.mp[nid]
if !ok {
@ -205,9 +203,7 @@ func (d *driver) peerDbAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask
return b, i
}
func (d *driver) peerDbDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerMac net.HardwareAddr, vtep net.IP, isLocal bool) (bool, int) {
func (d *driver) peerDbDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP, isLocal bool) (bool, int) {
d.peerDb.Lock()
pMap, ok := d.peerDb.mp[nid]
if !ok {
@ -340,9 +336,7 @@ func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
}
}
func (d *driver) peerAddOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerMac net.HardwareAddr, vtep net.IP, l2Miss, l3Miss, updateDB, localPeer bool) error {
func (d *driver) peerAddOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP, l2Miss, l3Miss, updateDB, localPeer bool) error {
if err := validateID(nid, eid); err != nil {
return err
}
@ -432,9 +426,7 @@ func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMas
}
}
func (d *driver) peerDeleteOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerMac net.HardwareAddr, vtep net.IP, localPeer bool) error {
func (d *driver) peerDeleteOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP, localPeer bool) error {
if err := validateID(nid, eid); err != nil {
return err
}

View file

@ -178,7 +178,6 @@ func (ep *endpoint) UnmarshalJSON(b []byte) (err error) {
tplist = append(tplist, tp)
}
ep.generic[netlabel.ExposedPorts] = tplist
}
}
@ -580,7 +579,6 @@ func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) (err error) {
ep.Name(), ep.ID(), err)
}
}
}
if !sb.needDefaultGW() {

View file

@ -7,7 +7,6 @@ import (
)
func TestErrorInterfaces(t *testing.T) {
badRequestErrorList := []error{ErrInvalidID(""), ErrInvalidName(""), ErrInvalidJoin{}, ErrInvalidNetworkDriver(""), InvalidContainerIDError(""), ErrNoSuchNetwork(""), ErrNoSuchEndpoint("")}
for _, err := range badRequestErrorList {
switch u := err.(type) {
@ -47,5 +46,4 @@ func TestErrorInterfaces(t *testing.T) {
t.Fatalf("Failed to detect err %v is of type ForbiddenError. Got type: %T", err, u)
}
}
}

View file

@ -209,7 +209,6 @@ func TestUpdateIgnoresPrefixedHostname(t *testing.T) {
if expected := "5.5.5.5\tprefix\n3.3.3.3\tprefixAndMore\n4.4.4.4\tunaffectedHost\n"; !bytes.Contains(content, []byte(expected)) {
t.Fatalf("Expected to find '%s' got '%s'", expected, content)
}
}
// This regression test covers the host prefix issue for the

View file

@ -1056,7 +1056,6 @@ func TestOverlappingRequests(t *testing.T) {
}
func TestUnusualSubnets(t *testing.T) {
subnet := "192.168.0.2/31"
outsideTheRangeAddresses := []struct {
@ -1075,7 +1074,6 @@ func TestUnusualSubnets(t *testing.T) {
}
for _, store := range []bool{false, true} {
allocator, err := getAllocator(store)
if err != nil {
t.Fatal(err)
@ -1117,7 +1115,6 @@ func TestUnusualSubnets(t *testing.T) {
if err != ipamapi.ErrNoAvailableIPs {
t.Fatal("Did not get expected error when pool is exhausted.")
}
}
}
@ -1264,7 +1261,6 @@ func benchmarkRequest(b *testing.B, a *Allocator, subnet string) {
}
func BenchmarkRequest(b *testing.B) {
subnets := []string{
"10.0.0.0/24",
"10.0.0.0/16",

View file

@ -56,5 +56,4 @@ func TestOtherRequests(t *testing.T) {
if err == nil {
t.Fatal("Unexpected success")
}
}

View file

@ -206,7 +206,7 @@ func getDockerZoneSettings() []interface{} {
description: "zone for docker bridge network interfaces",
target: "ACCEPT",
}
slice := []interface{}{
return []interface{}{
settings.version,
settings.name,
settings.description,
@ -224,8 +224,6 @@ func getDockerZoneSettings() []interface{} {
settings.sourcePorts,
settings.icmpBlockInversion,
}
return slice
}
// setupDockerZone creates a zone called docker in firewalld which includes docker interfaces to allow

View file

@ -90,5 +90,4 @@ func TestPassthrough(t *testing.T) {
t.Fatal("rule1 does not exist")
}
}
}

View file

@ -260,7 +260,6 @@ func (iptable IPTable) ProgramChain(c *ChainInfo, bridgeName string, hairpinMode
} else if len(output) != 0 {
return fmt.Errorf("Could not delete linking rule from %s/%s: %s", c.Table, c.Name, output)
}
}
establish := []string{
"-o", bridgeName,
@ -301,7 +300,6 @@ func (iptable IPTable) RemoveExistingChain(name string, table Table) error {
// Forward adds forwarding rule to 'filter' table and corresponding nat rule to 'nat' table.
func (c *ChainInfo) Forward(action Action, ip net.IP, port int, proto, destAddr string, destPort int, bridgeName string) error {
iptable := GetIptable(c.IPTable.Version)
daddr := ip.String()
if ip.IsUnspecified() {

View file

@ -334,7 +334,6 @@ func TestAuxAddresses(t *testing.T) {
}
for _, i := range input {
n.ipamV4Config = []*IpamConf{{PreferredPool: i.masterPool, SubPool: i.subPool, AuxAddresses: i.auxAddresses}}
err = n.ipamAllocate()

View file

@ -400,7 +400,6 @@ func TestNetworkConfig(t *testing.T) {
if err := configNetwork.Delete(); err != nil {
t.Fatal(err)
}
}
func TestUnknownNetwork(t *testing.T) {
@ -1054,7 +1053,6 @@ func TestEndpointMultipleJoins(t *testing.T) {
if _, ok := err.(types.ForbiddenError); !ok {
t.Fatalf("Failed with unexpected error type: %T. Desc: %s", err, err.Error())
}
}
func TestLeaveAll(t *testing.T) {

View file

@ -1168,7 +1168,6 @@ func (n *network) CreateEndpoint(name string, options ...EndpointOption) (Endpoi
defer n.ctrlr.networkLocker.Unlock(n.id) //nolint:errcheck
return n.createEndpoint(name, options...)
}
func (n *network) createEndpoint(name string, options ...EndpointOption) (Endpoint, error) {
@ -1953,7 +1952,6 @@ func (n *network) TableEventRegister(tableName string, objType driverapi.ObjectT
}
func (n *network) UpdateIpamConfig(ipV4Data []driverapi.IPAMData) {
ipamV4Config := make([]*IpamConf, len(ipV4Data))
for i, data := range ipV4Data {
@ -2233,7 +2231,6 @@ func (n *network) deleteLoadBalancerSandbox() error {
if err != nil {
logrus.Warnf("Failed to find load balancer endpoint %s on network %s: %v", endpointName, name, err)
} else {
info := endpoint.Info()
if info != nil {
sb := info.Sandbox()

View file

@ -200,7 +200,6 @@ func (nDB *NetworkDB) retryJoin(ctx context.Context, members []string) {
return
}
}
}
func (nDB *NetworkDB) clusterJoin(members []string) error {

View file

@ -177,7 +177,6 @@ func GenerateKey(containerID string) string {
index = tmpindex
tmpkey = id
}
}
}
containerID = tmpkey

View file

@ -183,7 +183,6 @@ func (n *networkNamespace) AddStaticRoute(r *types.StaticRoute) error {
}
func (n *networkNamespace) RemoveStaticRoute(r *types.StaticRoute) error {
err := n.removeRoute(n.nsPath(), r.Destination, r.NextHop)
if err == nil {
n.Lock()

View file

@ -321,7 +321,6 @@ func TestSetInterfaceIP(t *testing.T) {
}
func TestLiveRestore(t *testing.T) {
defer testutils.SetupTestOSContext(t)()
key, err := newKey(t)

View file

@ -347,7 +347,6 @@ func (r *resolver) handleSRVQuery(query *dns.Msg) (*dns.Msg, error) {
resp.Extra = append(resp.Extra, rr1)
}
return resp, nil
}
func truncateResp(resp *dns.Msg, maxSize int, isTCP bool) {

View file

@ -166,7 +166,6 @@ func TestDNSIPQuery(t *testing.T) {
t.Log("Response: ", resp.String())
checkDNSResponseCode(t, resp, dns.RcodeServerFailure)
w.ClearResponse()
}
func newDNSHandlerServFailOnce(requests *int) func(w dns.ResponseWriter, r *dns.Msg) {

View file

@ -569,7 +569,6 @@ func (sb *sandbox) ResolveName(name string, ipType int) ([]net.IP, bool) {
}
for i := 0; i < len(reqName); i++ {
// First check for local container alias
ip, ipv6Miss := sb.resolveName(reqName[i], networkName[i], epList, true, ipType)
if ip != nil {

View file

@ -209,9 +209,7 @@ func (sb *sandbox) setupDNS() error {
// When the user specify a conainter in the host namespace and do no have any dns option specified
// we just copy the host resolv.conf from the host itself
if sb.config.useDefaultSandBox &&
len(sb.config.dnsList) == 0 && len(sb.config.dnsSearchList) == 0 && len(sb.config.dnsOptionsList) == 0 {
if sb.config.useDefaultSandBox && len(sb.config.dnsList) == 0 && len(sb.config.dnsSearchList) == 0 && len(sb.config.dnsOptionsList) == 0 {
// We are working under the assumption that the origin file option had been properly expressed by the upper layer
// if not here we are going to error out
if err := copyFile(sb.config.originResolvConfPath, sb.config.resolvConfPath); err != nil {
@ -325,7 +323,7 @@ func (sb *sandbox) updateDNS(ipv6Enabled bool) error {
if currHash != "" && currHash != currRC.Hash {
// Seems the user has changed the container resolv.conf since the last time
// we checked so return without doing anything.
//logrus.Infof("Skipping update of resolv.conf file with ipv6Enabled: %t because file was touched by user", ipv6Enabled)
// logrus.Infof("Skipping update of resolv.conf file with ipv6Enabled: %t because file was touched by user", ipv6Enabled)
return nil
}

View file

@ -213,7 +213,6 @@ func (c *controller) cleanupServiceBindings(cleanupNID string) {
for _, f := range cleanupFuncs {
f()
}
}
func makeServiceCleanupFunc(c *controller, s *service, nID, eID string, vip net.IP, ip net.IP) func() {
@ -315,7 +314,6 @@ func (c *controller) addServiceBinding(svcName, svcID, nID, eID, containerName s
}
func (c *controller) rmServiceBinding(svcName, svcID, nID, eID, containerName string, vip net.IP, ingressPorts []*PortConfig, serviceAliases []string, taskAliases []string, ip net.IP, method string, deleteSvcRecords bool, fullRemove bool) error {
var rmService bool
skey := serviceKey{

View file

@ -319,7 +319,6 @@ func (c *controller) networkWatchLoop(nw *netWatch, ep *endpoint, ecCh <-chan da
for _, lEp := range delEpMap {
ep.getNetwork().updateSvcRecord(lEp, c.getLocalEps(nw), false)
}
for _, lEp := range addEp {
ep.getNetwork().updateSvcRecord(lEp, c.getLocalEps(nw), true)

View file

@ -14,7 +14,6 @@ func TestBoltdbBackend(t *testing.T) {
defer os.Remove("/tmp/boltdb.db")
config := &store.Config{Bucket: "testBackend"}
testLocalBackend(t, "boltdb", "/tmp/boltdb.db", config)
}
func TestNoPersist(t *testing.T) {