libnetwork/drivers/bridge: format code with gofumpt
Formatting the code with https://github.com/mvdan/gofumpt Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
d2a6956afb
commit
17a35bc645
12 changed files with 30 additions and 21 deletions
|
@ -50,8 +50,10 @@ func (d defaultBridgeNetworkConflict) Error() string {
|
|||
return fmt.Sprintf("Stale default bridge network %s", d.ID)
|
||||
}
|
||||
|
||||
type iptableCleanFunc func() error
|
||||
type iptablesCleanFuncs []iptableCleanFunc
|
||||
type (
|
||||
iptableCleanFunc func() error
|
||||
iptablesCleanFuncs []iptableCleanFunc
|
||||
)
|
||||
|
||||
// configuration info for the "bridge" driver.
|
||||
type configuration struct {
|
||||
|
@ -969,7 +971,8 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
|
|||
// Generate and add the interface pipe host <-> sandbox
|
||||
veth := &netlink.Veth{
|
||||
LinkAttrs: netlink.LinkAttrs{Name: hostIfName, TxQLen: 0},
|
||||
PeerName: containerIfName}
|
||||
PeerName: containerIfName,
|
||||
}
|
||||
if err = d.nlh.LinkAdd(veth); err != nil {
|
||||
return types.InternalErrorf("failed to add the host (%s) <=> sandbox (%s) pair interfaces: %v", hostIfName, containerIfName, err)
|
||||
}
|
||||
|
|
|
@ -52,8 +52,7 @@ func (l *link) Disable() {
|
|||
// that returns typed errors
|
||||
}
|
||||
|
||||
func linkContainers(action, parentIP, childIP string, ports []types.TransportPort, bridge string,
|
||||
ignoreErrors bool) error {
|
||||
func linkContainers(action, parentIP, childIP string, ports []types.TransportPort, bridge string, ignoreErrors bool) error {
|
||||
var nfAction iptables.Action
|
||||
|
||||
switch action {
|
||||
|
|
|
@ -116,7 +116,8 @@ func TestLinkCreateTwo(t *testing.T) {
|
|||
|
||||
config := &networkConfiguration{
|
||||
BridgeName: DefaultBridgeName,
|
||||
EnableIPv6: true}
|
||||
EnableIPv6: true,
|
||||
}
|
||||
genericOption := make(map[string]interface{})
|
||||
genericOption[netlabel.GenericData] = config
|
||||
|
||||
|
@ -152,7 +153,8 @@ func TestLinkCreateNoEnableIPv6(t *testing.T) {
|
|||
}
|
||||
|
||||
config := &networkConfiguration{
|
||||
BridgeName: DefaultBridgeName}
|
||||
BridgeName: DefaultBridgeName,
|
||||
}
|
||||
genericOption := make(map[string]interface{})
|
||||
genericOption[netlabel.GenericData] = config
|
||||
|
||||
|
@ -187,7 +189,8 @@ func TestLinkDelete(t *testing.T) {
|
|||
|
||||
config := &networkConfiguration{
|
||||
BridgeName: DefaultBridgeName,
|
||||
EnableIPv6: true}
|
||||
EnableIPv6: true,
|
||||
}
|
||||
genericOption := make(map[string]interface{})
|
||||
genericOption[netlabel.GenericData] = config
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ func setKernelBoolParam(path string, on bool) error {
|
|||
if on {
|
||||
value = byte('1')
|
||||
}
|
||||
return os.WriteFile(path, []byte{value, '\n'}, 0644)
|
||||
return os.WriteFile(path, []byte{value, '\n'}, 0o644)
|
||||
}
|
||||
|
||||
// Checks to see if packet forwarding is enabled
|
||||
|
|
|
@ -57,7 +57,7 @@ func setupDefaultSysctl(config *networkConfiguration, i *bridgeInterface) error
|
|||
Info("failed to read ipv6 net.ipv6.conf.<bridge>.accept_ra")
|
||||
return nil
|
||||
}
|
||||
if err := os.WriteFile(sysPath, []byte{'0', '\n'}, 0644); err != nil {
|
||||
if err := os.WriteFile(sysPath, []byte{'0', '\n'}, 0o644); err != nil {
|
||||
log.G(context.TODO()).WithError(err).Warn("unable to disable IPv6 router advertisement")
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
const (
|
||||
ipv4ForwardConf = "/proc/sys/net/ipv4/ip_forward"
|
||||
ipv4ForwardConfPerm = 0644
|
||||
ipv4ForwardConfPerm = 0o644
|
||||
)
|
||||
|
||||
func configureIPForwarding(enable bool) error {
|
||||
|
|
|
@ -203,7 +203,6 @@ type iptRule struct {
|
|||
}
|
||||
|
||||
func setupIPTablesInternal(hostIP net.IP, bridgeIface string, addr *net.IPNet, icc, ipmasq, hairpin, enable bool) error {
|
||||
|
||||
var (
|
||||
address = addr.String()
|
||||
skipDNAT = iptRule{table: iptables.Nat, chain: DockerChain, preArgs: []string{"-t", "nat"}, args: []string{"-i", bridgeIface, "-j", "RETURN"}}
|
||||
|
@ -260,7 +259,6 @@ func setupIPTablesInternal(hostIP net.IP, bridgeIface string, addr *net.IPNet, i
|
|||
}
|
||||
|
||||
func programChainRule(version iptables.IPVersion, rule iptRule, ruleDescr string, insert bool) error {
|
||||
|
||||
iptable := iptables.GetIptable(version)
|
||||
|
||||
var (
|
||||
|
|
|
@ -82,7 +82,8 @@ func TestSetupIPChains(t *testing.T) {
|
|||
func getBasicTestConfig() *networkConfiguration {
|
||||
config := &networkConfiguration{
|
||||
BridgeName: DefaultBridgeName,
|
||||
AddressIPv4: &net.IPNet{IP: net.ParseIP(iptablesTestBridgeIP), Mask: net.CIDRMask(16, 32)}}
|
||||
AddressIPv4: &net.IPNet{IP: net.ParseIP(iptablesTestBridgeIP), Mask: net.CIDRMask(16, 32)},
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
|
@ -128,8 +129,10 @@ func assertChainConfig(d *driver, t *testing.T) {
|
|||
|
||||
// Assert function which pushes chains based on bridge config parameters.
|
||||
func assertBridgeConfig(config *networkConfiguration, br *bridgeInterface, d *driver, t *testing.T) {
|
||||
nw := bridgeNetwork{portMapper: portmapper.New(""),
|
||||
config: config}
|
||||
nw := bridgeNetwork{
|
||||
portMapper: portmapper.New(""),
|
||||
config: config,
|
||||
}
|
||||
nw.driver = d
|
||||
|
||||
// Attempt programming of ip tables.
|
||||
|
|
|
@ -77,7 +77,7 @@ func setupLoopbackAddressesRouting(config *networkConfiguration, i *bridgeInterf
|
|||
}
|
||||
// Enable loopback addresses routing only if it isn't already enabled
|
||||
if ipv4LoRoutingData[0] != '1' {
|
||||
if err := os.WriteFile(sysPath, []byte{'1', '\n'}, 0644); err != nil {
|
||||
if err := os.WriteFile(sysPath, []byte{'1', '\n'}, 0o644); err != nil {
|
||||
return fmt.Errorf("Unable to enable local routing for hairpin mode: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ import (
|
|||
|
||||
func setupTestInterface(t *testing.T, nh *netlink.Handle) (*networkConfiguration, *bridgeInterface) {
|
||||
config := &networkConfiguration{
|
||||
BridgeName: DefaultBridgeName}
|
||||
BridgeName: DefaultBridgeName,
|
||||
}
|
||||
br := &bridgeInterface{nlh: nh}
|
||||
|
||||
if err := setupDevice(config, br); err != nil {
|
||||
|
@ -74,7 +75,8 @@ func TestSetupGatewayIPv4(t *testing.T) {
|
|||
|
||||
config := &networkConfiguration{
|
||||
BridgeName: DefaultBridgeName,
|
||||
DefaultGatewayIPv4: gw}
|
||||
DefaultGatewayIPv4: gw,
|
||||
}
|
||||
|
||||
br := &bridgeInterface{bridgeIPv4: nw, nlh: nh}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
var bridgeIPv6 = &net.IPNet{IP: net.ParseIP("fe80::1"), Mask: net.CIDRMask(64, 128)}
|
||||
|
||||
const (
|
||||
ipv6ForwardConfPerm = 0644
|
||||
ipv6ForwardConfPerm = 0o644
|
||||
ipv6ForwardConfDefault = "/proc/sys/net/ipv6/conf/default/forwarding"
|
||||
ipv6ForwardConfAll = "/proc/sys/net/ipv6/conf/all/forwarding"
|
||||
)
|
||||
|
|
|
@ -63,7 +63,8 @@ func TestSetupGatewayIPv6(t *testing.T) {
|
|||
config := &networkConfiguration{
|
||||
BridgeName: DefaultBridgeName,
|
||||
AddressIPv6: nw,
|
||||
DefaultGatewayIPv6: gw}
|
||||
DefaultGatewayIPv6: gw,
|
||||
}
|
||||
|
||||
nh, err := netlink.NewHandle()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue