Browse Source

libnetwork/osl: format code with gofumpt

Formatting the code with https://github.com/mvdan/gofumpt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 years ago
parent
commit
882f7bbf1f

+ 2 - 1
libnetwork/osl/interface_linux.go

@@ -352,7 +352,8 @@ func setInterfaceMaster(nlh *netlink.Handle, iface netlink.Link, i *nwIface) err
 	}
 	}
 
 
 	return nlh.LinkSetMaster(iface, &netlink.Bridge{
 	return nlh.LinkSetMaster(iface, &netlink.Bridge{
-		LinkAttrs: netlink.LinkAttrs{Name: i.DstMaster()}})
+		LinkAttrs: netlink.LinkAttrs{Name: i.DstMaster()},
+	})
 }
 }
 
 
 func setInterfaceMAC(nlh *netlink.Handle, iface netlink.Link, i *nwIface) error {
 func setInterfaceMAC(nlh *netlink.Handle, iface netlink.Link, i *nwIface) error {

+ 1 - 1
libnetwork/osl/kernel/knobs_linux.go

@@ -13,7 +13,7 @@ import (
 // For e.g. net.ipv4.ip_forward translated to /proc/sys/net/ipv4/ip_forward.
 // For e.g. net.ipv4.ip_forward translated to /proc/sys/net/ipv4/ip_forward.
 func writeSystemProperty(key, value string) error {
 func writeSystemProperty(key, value string) error {
 	keyPath := strings.ReplaceAll(key, ".", "/")
 	keyPath := strings.ReplaceAll(key, ".", "/")
-	return os.WriteFile(path.Join("/proc/sys", keyPath), []byte(value), 0644)
+	return os.WriteFile(path.Join("/proc/sys", keyPath), []byte(value), 0o644)
 }
 }
 
 
 // readSystemProperty reads the value from the path under /proc/sys and returns it
 // readSystemProperty reads the value from the path under /proc/sys and returns it

+ 3 - 3
libnetwork/osl/namespace_linux.go

@@ -73,7 +73,7 @@ func basePath() string {
 }
 }
 
 
 func createBasePath() {
 func createBasePath() {
-	err := os.MkdirAll(basePath(), 0755)
+	err := os.MkdirAll(basePath(), 0o755)
 	if err != nil {
 	if err != nil {
 		panic("Could not create net namespace path directory")
 		panic("Could not create net namespace path directory")
 	}
 	}
@@ -380,12 +380,12 @@ func (n *networkNamespace) DisableARPForVIP(srcName string) (Err error) {
 
 
 	err := n.InvokeFunc(func() {
 	err := n.InvokeFunc(func() {
 		path := filepath.Join("/proc/sys/net/ipv4/conf", dstName, "arp_ignore")
 		path := filepath.Join("/proc/sys/net/ipv4/conf", dstName, "arp_ignore")
-		if err := os.WriteFile(path, []byte{'1', '\n'}, 0644); err != nil {
+		if err := os.WriteFile(path, []byte{'1', '\n'}, 0o644); err != nil {
 			Err = fmt.Errorf("Failed to set %s to 1: %v", path, err)
 			Err = fmt.Errorf("Failed to set %s to 1: %v", path, err)
 			return
 			return
 		}
 		}
 		path = filepath.Join("/proc/sys/net/ipv4/conf", dstName, "arp_announce")
 		path = filepath.Join("/proc/sys/net/ipv4/conf", dstName, "arp_announce")
-		if err := os.WriteFile(path, []byte{'2', '\n'}, 0644); err != nil {
+		if err := os.WriteFile(path, []byte{'2', '\n'}, 0o644); err != nil {
 			Err = fmt.Errorf("Failed to set %s to 2: %v", path, err)
 			Err = fmt.Errorf("Failed to set %s to 2: %v", path, err)
 			return
 			return
 		}
 		}

+ 4 - 2
libnetwork/osl/sandbox_linux_test.go

@@ -58,7 +58,8 @@ func newKey(t *testing.T) (string, error) {
 func newInfo(hnd *netlink.Handle, t *testing.T) (Sandbox, error) {
 func newInfo(hnd *netlink.Handle, t *testing.T) (Sandbox, error) {
 	veth := &netlink.Veth{
 	veth := &netlink.Veth{
 		LinkAttrs: netlink.LinkAttrs{Name: vethName1, TxQLen: 0},
 		LinkAttrs: netlink.LinkAttrs{Name: vethName1, TxQLen: 0},
-		PeerName:  vethName2}
+		PeerName:  vethName2,
+	}
 	if err := hnd.LinkAdd(veth); err != nil {
 	if err := hnd.LinkAdd(veth); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -97,7 +98,8 @@ func newInfo(hnd *netlink.Handle, t *testing.T) (Sandbox, error) {
 
 
 	veth = &netlink.Veth{
 	veth = &netlink.Veth{
 		LinkAttrs: netlink.LinkAttrs{Name: vethName3, TxQLen: 0},
 		LinkAttrs: netlink.LinkAttrs{Name: vethName3, TxQLen: 0},
-		PeerName:  vethName4}
+		PeerName:  vethName4,
+	}
 
 
 	if err := hnd.LinkAdd(veth); err != nil {
 	if err := hnd.LinkAdd(veth); err != nil {
 		return nil, err
 		return nil, err

+ 2 - 4
libnetwork/osl/sandbox_unsupported.go

@@ -4,10 +4,8 @@ package osl
 
 
 import "errors"
 import "errors"
 
 
-var (
-	// ErrNotImplemented is for platforms which don't implement sandbox
-	ErrNotImplemented = errors.New("not implemented")
-)
+// ErrNotImplemented is for platforms which don't implement sandbox
+var ErrNotImplemented = errors.New("not implemented")
 
 
 // NewSandbox provides a new sandbox instance created in an os specific way
 // NewSandbox provides a new sandbox instance created in an os specific way
 // provided a key which uniquely identifies the sandbox
 // provided a key which uniquely identifies the sandbox