libnetwork/osl: 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:
Sebastiaan van Stijn 2022-01-20 14:07:26 +01:00
parent 32e716e848
commit 882f7bbf1f
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
5 changed files with 12 additions and 11 deletions

View file

@ -352,7 +352,8 @@ func setInterfaceMaster(nlh *netlink.Handle, iface netlink.Link, i *nwIface) err
}
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 {

View file

@ -13,7 +13,7 @@ import (
// For e.g. net.ipv4.ip_forward translated to /proc/sys/net/ipv4/ip_forward.
func writeSystemProperty(key, value string) error {
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

View file

@ -73,7 +73,7 @@ func basePath() string {
}
func createBasePath() {
err := os.MkdirAll(basePath(), 0755)
err := os.MkdirAll(basePath(), 0o755)
if err != nil {
panic("Could not create net namespace path directory")
}
@ -380,12 +380,12 @@ func (n *networkNamespace) DisableARPForVIP(srcName string) (Err error) {
err := n.InvokeFunc(func() {
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)
return
}
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)
return
}

View file

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

View file

@ -4,10 +4,8 @@ package osl
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
// provided a key which uniquely identifies the sandbox