libnetwork: 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
bba21735bf
commit
dd5ea7e996
14 changed files with 40 additions and 35 deletions
|
@ -947,7 +947,6 @@ func (c *Controller) NewSandbox(containerID string, options ...SandboxOption) (*
|
|||
err := sb.osSbox.InvokeFunc(func() {
|
||||
sb.osSbox.ApplyOSTweaks(sb.oslTypes)
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.G(context.TODO()).Errorf("Failed to apply performance tuning sysctls to the sandbox: %v", err)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ func (c *Controller) createGWNetwork() (Network, error) {
|
|||
NetworkOptionDriverOpts(netOption),
|
||||
NetworkOptionEnableIPv6(false),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating external connectivity network: %v", err)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
const libnGWNetwork = "nat"
|
||||
|
||||
func getPlatformOption() EndpointOption {
|
||||
|
||||
epOption := options.Generic{
|
||||
windriver.DisableICC: true,
|
||||
windriver.DisableDNS: true,
|
||||
|
|
|
@ -649,39 +649,51 @@ func (b *badDriver) CreateNetwork(nid string, options map[string]interface{}, nI
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *badDriver) DeleteNetwork(nid string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *badDriver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, options map[string]interface{}) error {
|
||||
return fmt.Errorf("I will not create any endpoint")
|
||||
}
|
||||
|
||||
func (b *badDriver) DeleteEndpoint(nid, eid string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *badDriver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (b *badDriver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
||||
return fmt.Errorf("I will not allow any join")
|
||||
}
|
||||
|
||||
func (b *badDriver) Leave(nid, eid string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *badDriver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *badDriver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *badDriver) Type() string {
|
||||
return badDriverName
|
||||
}
|
||||
|
||||
func (b *badDriver) IsBuiltIn() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (b *badDriver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *badDriver) RevokeExternalConnectivity(nid, eid string) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -565,7 +565,7 @@ func TestEnableIPv6(t *testing.T) {
|
|||
}
|
||||
// cleanup
|
||||
defer func() {
|
||||
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
|
||||
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
@ -593,7 +593,7 @@ func TestEnableIPv6(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
|
||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,7 @@ func TestResolvConfHost(t *testing.T) {
|
|||
}
|
||||
// cleanup
|
||||
defer func() {
|
||||
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
|
||||
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
@ -653,7 +653,7 @@ func TestResolvConfHost(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
|
||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -689,7 +689,7 @@ func TestResolvConfHost(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fmode := (os.FileMode)(0644)
|
||||
fmode := (os.FileMode)(0o644)
|
||||
if finfo.Mode() != fmode {
|
||||
t.Fatalf("Expected file mode %s, got %s", fmode.String(), finfo.Mode().String())
|
||||
}
|
||||
|
@ -720,7 +720,7 @@ func TestResolvConf(t *testing.T) {
|
|||
}
|
||||
// cleanup
|
||||
defer func() {
|
||||
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
|
||||
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
@ -745,7 +745,7 @@ func TestResolvConf(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf1, 0644); err != nil {
|
||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf1, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -772,7 +772,7 @@ func TestResolvConf(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fmode := (os.FileMode)(0644)
|
||||
fmode := (os.FileMode)(0o644)
|
||||
if finfo.Mode() != fmode {
|
||||
t.Fatalf("Expected file mode %s, got %s", fmode.String(), finfo.Mode().String())
|
||||
}
|
||||
|
@ -792,7 +792,7 @@ func TestResolvConf(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf2, 0644); err != nil {
|
||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf2, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -820,7 +820,7 @@ func TestResolvConf(t *testing.T) {
|
|||
t.Fatalf("Expected:\n%s\nGot:\n%s", string(expectedResolvConf1), string(content))
|
||||
}
|
||||
|
||||
if err := os.WriteFile(resolvConfPath, tmpResolvConf3, 0644); err != nil {
|
||||
if err := os.WriteFile(resolvConfPath, tmpResolvConf3, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
@ -1172,7 +1172,7 @@ func TestInvalidRemoteDriver(t *testing.T) {
|
|||
fmt.Fprintln(w, `{"Implements": ["InvalidDriver"]}`)
|
||||
})
|
||||
|
||||
if err := os.MkdirAll(specPath, 0755); err != nil {
|
||||
if err := os.MkdirAll(specPath, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() {
|
||||
|
@ -1181,7 +1181,7 @@ func TestInvalidRemoteDriver(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
if err := os.WriteFile(filepath.Join(specPath, "invalid-network-driver.spec"), []byte(server.URL), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(specPath, "invalid-network-driver.spec"), []byte(server.URL), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -1227,7 +1227,7 @@ func TestValidRemoteDriver(t *testing.T) {
|
|||
fmt.Fprintf(w, "null")
|
||||
})
|
||||
|
||||
if err := os.MkdirAll(specPath, 0755); err != nil {
|
||||
if err := os.MkdirAll(specPath, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() {
|
||||
|
@ -1236,7 +1236,7 @@ func TestValidRemoteDriver(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
if err := os.WriteFile(filepath.Join(specPath, "valid-network-driver.spec"), []byte(server.URL), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(specPath, "valid-network-driver.spec"), []byte(server.URL), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,4 @@ import (
|
|||
|
||||
const bridgeNetType = "nat"
|
||||
|
||||
var (
|
||||
specPath = filepath.Join(os.Getenv("programdata"), "docker", "plugins")
|
||||
)
|
||||
var specPath = filepath.Join(os.Getenv("programdata"), "docker", "plugins")
|
||||
|
|
|
@ -1643,7 +1643,7 @@ func (n *network) ipamAllocateVersion(ipVer int, ipam ipamapi.Ipam) error {
|
|||
// irrespective of whether ipam driver returned a gateway already.
|
||||
// If none of the above is true, libnetwork will allocate one.
|
||||
if cfg.Gateway != "" || d.Gateway == nil {
|
||||
var gatewayOpts = map[string]string{
|
||||
gatewayOpts := map[string]string{
|
||||
ipamapi.RequestAddressType: netlabel.Gateway,
|
||||
}
|
||||
if d.Gateway, _, err = ipam.RequestAddress(d.PoolID, net.ParseIP(cfg.Gateway), gatewayOpts); err != nil {
|
||||
|
@ -1919,7 +1919,7 @@ func (n *network) Labels() map[string]string {
|
|||
n.mu.Lock()
|
||||
defer n.mu.Unlock()
|
||||
|
||||
var lbls = make(map[string]string, len(n.labels))
|
||||
lbls := make(map[string]string, len(n.labels))
|
||||
for k, v := range n.labels {
|
||||
lbls[k] = v
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ func newMockProxyCommand(proto string, hostIP net.IP, hostPort int, containerIP
|
|||
return &mockProxyCommand{}, nil
|
||||
}
|
||||
|
||||
type mockProxyCommand struct {
|
||||
}
|
||||
type mockProxyCommand struct{}
|
||||
|
||||
func (p *mockProxyCommand) Start() error {
|
||||
return nil
|
||||
|
|
|
@ -1175,9 +1175,7 @@ func OptionLoadBalancer(nid string) SandboxOption {
|
|||
// epi.joininfo <=> epj.joininfo # ipv6 < ipv4
|
||||
// epi.name <=> epj.name # bar < foo
|
||||
func (epi *Endpoint) Less(epj *Endpoint) bool {
|
||||
var (
|
||||
prioi, prioj int
|
||||
)
|
||||
var prioi, prioj int
|
||||
|
||||
sbi, _ := epi.getSandbox()
|
||||
sbj, _ := epj.getSandbox()
|
||||
|
|
|
@ -105,7 +105,7 @@ func (c *Controller) startExternalKeyListener() error {
|
|||
execRoot = v
|
||||
}
|
||||
udsBase := filepath.Join(execRoot, execSubdir)
|
||||
if err := os.MkdirAll(udsBase, 0600); err != nil {
|
||||
if err := os.MkdirAll(udsBase, 0o600); err != nil {
|
||||
return err
|
||||
}
|
||||
shortCtlrID := stringid.TruncateID(c.id)
|
||||
|
@ -114,7 +114,7 @@ func (c *Controller) startExternalKeyListener() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Chmod(uds, 0600); err != nil {
|
||||
if err := os.Chmod(uds, 0o600); err != nil {
|
||||
l.Close()
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -562,7 +562,7 @@ func (sb *Sandbox) configureFWMark(vip net.IP, fwMark uint32, ingressPorts []*Po
|
|||
rule := append([]string{"-t", "nat", "-A", "POSTROUTING"}, ruleParams...)
|
||||
rules = append(rules, rule)
|
||||
|
||||
err := os.WriteFile("/proc/sys/net/ipv4/vs/conntrack", []byte{'1', '\n'}, 0644)
|
||||
err := os.WriteFile("/proc/sys/net/ipv4/vs/conntrack", []byte{'1', '\n'}, 0o644)
|
||||
if err != nil {
|
||||
innerErr = err
|
||||
return
|
||||
|
|
|
@ -25,7 +25,7 @@ func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
|
|||
|
||||
lb.Lock()
|
||||
defer lb.Unlock()
|
||||
//find the load balancer IP for the network.
|
||||
// find the load balancer IP for the network.
|
||||
var sourceVIP string
|
||||
for _, e := range n.Endpoints() {
|
||||
epInfo := e.Info()
|
||||
|
@ -49,7 +49,7 @@ func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
|
|||
if be.disabled {
|
||||
continue
|
||||
}
|
||||
//Call HNS to get back ID (GUID) corresponding to the endpoint.
|
||||
// Call HNS to get back ID (GUID) corresponding to the endpoint.
|
||||
hnsEndpoint, err := hcsshim.GetHNSEndpointByName(eid)
|
||||
if err != nil {
|
||||
log.G(context.TODO()).Errorf("Failed to find HNS ID for endpoint %v: %v", eid, err)
|
||||
|
|
|
@ -379,9 +379,10 @@ type StaticRoute struct {
|
|||
func (r *StaticRoute) GetCopy() *StaticRoute {
|
||||
d := GetIPNetCopy(r.Destination)
|
||||
nh := GetIPCopy(r.NextHop)
|
||||
return &StaticRoute{Destination: d,
|
||||
RouteType: r.RouteType,
|
||||
NextHop: nh,
|
||||
return &StaticRoute{
|
||||
Destination: d,
|
||||
RouteType: r.RouteType,
|
||||
NextHop: nh,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue