diff --git a/network/bridge_endpointclient_linux.go b/network/bridge_endpointclient_linux.go index 1150e37bf..9d2ac09a6 100644 --- a/network/bridge_endpointclient_linux.go +++ b/network/bridge_endpointclient_linux.go @@ -41,7 +41,6 @@ func NewLinuxBridgeEndpointClient( nl netlink.NetlinkInterface, plc platform.ExecClient, ) *LinuxBridgeEndpointClient { - client := &LinuxBridgeEndpointClient{ bridgeName: extIf.BridgeName, hostPrimaryIfName: extIf.Name, diff --git a/network/endpoint_windows.go b/network/endpoint_windows.go index ed25d3f4e..0889e59d1 100644 --- a/network/endpoint_windows.go +++ b/network/endpoint_windows.go @@ -64,7 +64,6 @@ func ConstructEndpointID(containerID string, netNsPath string, ifName string) (s // newEndpointImpl creates a new endpoint in the network. func (nw *network) newEndpointImpl(cli apipaClient, _ netlink.NetlinkInterface, _ platform.ExecClient, epInfo *EndpointInfo) (*endpoint, error) { - if useHnsV2, err := UseHnsV2(epInfo.NetNsPath); useHnsV2 { if err != nil { return nil, err @@ -115,7 +114,6 @@ func (nw *network) newEndpointImplHnsV1(epInfo *EndpointInfo) (*endpoint, error) } hnsResponse, err := Hnsv1.CreateEndpoint(hnsEndpoint, "") - if err != nil { return nil, err } @@ -290,8 +288,7 @@ func (nw *network) createHostNCApipaEndpoint(cli apipaClient, epInfo *EndpointIn log.Printf("[net] Creating HostNCApipaEndpoint for host container connectivity for NC: %s", epInfo.NetworkContainerID) - if hostNCApipaEndpointID, err = - cli.CreateHostNCApipaEndpoint(context.TODO(), epInfo.NetworkContainerID); err != nil { + if hostNCApipaEndpointID, err = cli.CreateHostNCApipaEndpoint(context.TODO(), epInfo.NetworkContainerID); err != nil { return err } diff --git a/network/endpoint_windows_test.go b/network/endpoint_windows_test.go index 726cd8503..32bc79c8c 100644 --- a/network/endpoint_windows_test.go +++ b/network/endpoint_windows_test.go @@ -40,7 +40,6 @@ func TestNewAndDeleteEndpointImplHnsV2(t *testing.T) { MacAddress: net.HardwareAddr("00:00:5e:00:53:01"), } endpoint, err := nw.newEndpointImplHnsV2(nil, epInfo) - if err != nil { fmt.Printf("+%v", err) t.Fatal(err) @@ -89,7 +88,6 @@ func TestNewEndpointImplHnsv2Timesout(t *testing.T) { if err == nil { t.Fatal("Failed to timeout HNS calls for creating endpoint") } - } func TestDeleteEndpointImplHnsv2Timeout(t *testing.T) { @@ -113,7 +111,6 @@ func TestDeleteEndpointImplHnsv2Timeout(t *testing.T) { MacAddress: net.HardwareAddr("00:00:5e:00:53:01"), } endpoint, err := nw.newEndpointImplHnsV2(nil, epInfo) - if err != nil { fmt.Printf("+%v", err) t.Fatal(err) @@ -167,7 +164,6 @@ func TestCreateEndpointImplHnsv1Timeout(t *testing.T) { if err == nil { t.Fatal("Failed to timeout HNS calls for creating endpoint") } - } func TestDeleteEndpointImplHnsv1Timeout(t *testing.T) { @@ -191,7 +187,6 @@ func TestDeleteEndpointImplHnsv1Timeout(t *testing.T) { MacAddress: net.HardwareAddr("00:00:5e:00:53:01"), } endpoint, err := nw.newEndpointImplHnsV1(epInfo) - if err != nil { fmt.Printf("+%v", err) t.Fatal(err) diff --git a/network/hnsendpoint_mock_windows.go b/network/hnsendpoint_mock_windows.go index 1a09cbcbb..7556a7635 100644 --- a/network/hnsendpoint_mock_windows.go +++ b/network/hnsendpoint_mock_windows.go @@ -2,6 +2,7 @@ package network import ( "errors" + "github.com/Microsoft/hcsshim" ) @@ -12,9 +13,11 @@ type MockHNSEndpoint struct { } func NewMockHNSEndpoint(isAttached bool, hotAttachFailure bool) *MockHNSEndpoint { - return &MockHNSEndpoint{HnsIDMap: make(map[string]*hcsshim.HNSEndpoint), + return &MockHNSEndpoint{ + HnsIDMap: make(map[string]*hcsshim.HNSEndpoint), IsAttachedFlag: isAttached, - HotAttachFailure: hotAttachFailure} + HotAttachFailure: hotAttachFailure, + } } func (az *MockHNSEndpoint) GetHNSEndpointByName(endpointName string) (*hcsshim.HNSEndpoint, error) { diff --git a/network/hnswrapper/hnsv1wrapper.go b/network/hnswrapper/hnsv1wrapper.go index 55c117347..cb5c39f8a 100644 --- a/network/hnswrapper/hnsv1wrapper.go +++ b/network/hnswrapper/hnsv1wrapper.go @@ -10,8 +10,7 @@ import ( "github.com/Microsoft/hcsshim" ) -type Hnsv1wrapper struct { -} +type Hnsv1wrapper struct{} func (Hnsv1wrapper) CreateEndpoint(endpoint *hcsshim.HNSEndpoint, path string) (*hcsshim.HNSEndpoint, error) { // Marshal the request. @@ -35,13 +34,11 @@ func (Hnsv1wrapper) CreateEndpoint(endpoint *hcsshim.HNSEndpoint, path string) ( func (Hnsv1wrapper) DeleteEndpoint(endpointId string) (*hcsshim.HNSEndpoint, error) { hnsResponse, err := hcsshim.HNSEndpointRequest("DELETE", endpointId, "") - if err != nil { return nil, err } return hnsResponse, err - } func (Hnsv1wrapper) CreateNetwork(network *hcsshim.HNSNetwork, path string) (*hcsshim.HNSNetwork, error) { @@ -66,7 +63,6 @@ func (Hnsv1wrapper) CreateNetwork(network *hcsshim.HNSNetwork, path string) (*hc func (Hnsv1wrapper) DeleteNetwork(networkId string) (*hcsshim.HNSNetwork, error) { hnsResponse, err := hcsshim.HNSNetworkRequest("DELETE", networkId, "") - if err != nil { return nil, err } diff --git a/network/hnswrapper/hnsv1wrapperwithtimeout.go b/network/hnswrapper/hnsv1wrapperwithtimeout.go index d7c0ab126..0b55a92b5 100644 --- a/network/hnswrapper/hnsv1wrapperwithtimeout.go +++ b/network/hnswrapper/hnsv1wrapperwithtimeout.go @@ -5,9 +5,10 @@ package hnswrapper import ( "context" + "time" + "github.com/Microsoft/hcsshim" "github.com/pkg/errors" - "time" ) type Hnsv1wrapperwithtimeout struct { diff --git a/network/hnswrapper/hnsv2wrapper.go b/network/hnswrapper/hnsv2wrapper.go index 7a5b9570a..f37515694 100644 --- a/network/hnswrapper/hnsv2wrapper.go +++ b/network/hnswrapper/hnsv2wrapper.go @@ -10,8 +10,7 @@ import ( "github.com/Microsoft/hcsshim/hcn" ) -type Hnsv2wrapper struct { -} +type Hnsv2wrapper struct{} func (Hnsv2wrapper) CreateEndpoint(endpoint *hcn.HostComputeEndpoint) (*hcn.HostComputeEndpoint, error) { return endpoint.Create() diff --git a/network/network_windows.go b/network/network_windows.go index 09ff5b9ae..b440e0184 100644 --- a/network/network_windows.go +++ b/network/network_windows.go @@ -65,14 +65,14 @@ var Hnsv1 hnswrapper.HnsV1WrapperInterface = hnswrapper.Hnsv1wrapper{} func EnableHnsV2Timeout(timeoutValue int) { if _, ok := Hnsv2.(hnswrapper.Hnsv2wrapperwithtimeout); !ok { - var timeoutDuration = time.Duration(timeoutValue) * time.Second + timeoutDuration := time.Duration(timeoutValue) * time.Second Hnsv2 = hnswrapper.Hnsv2wrapperwithtimeout{Hnsv2: hnswrapper.Hnsv2wrapper{}, HnsCallTimeout: timeoutDuration} } } func EnableHnsV1Timeout(timeoutValue int) { if _, ok := Hnsv1.(hnswrapper.Hnsv1wrapperwithtimeout); !ok { - var timeoutDuration = time.Duration(timeoutValue) * time.Second + timeoutDuration := time.Duration(timeoutValue) * time.Second Hnsv1 = hnswrapper.Hnsv1wrapperwithtimeout{Hnsv1: hnswrapper.Hnsv1wrapper{}, HnsCallTimeout: timeoutDuration} } } diff --git a/network/network_windows_test.go b/network/network_windows_test.go index 6eee00013..4302ae402 100644 --- a/network/network_windows_test.go +++ b/network/network_windows_test.go @@ -37,7 +37,6 @@ func TestNewAndDeleteNetworkImplHnsV2(t *testing.T) { } network, err := nm.newNetworkImplHnsV2(nwInfo, extInterface) - if err != nil { fmt.Printf("+%v", err) t.Fatal(err) @@ -137,7 +136,6 @@ func TestDeleteNetworkImplHnsV2WithTimeout(t *testing.T) { Hnsv2 = hnswrapper.NewHnsv2wrapperFake() network, err := nm.newNetworkImplHnsV2(nwInfo, extInterface) - if err != nil { fmt.Printf("+%v", err) t.Fatal(err) @@ -210,7 +208,6 @@ func TestDeleteNetworkImplHnsV1WithTimeout(t *testing.T) { Hnsv1 = hnswrapper.NewHnsv1wrapperFake() network, err := nm.newNetworkImplHnsV1(nwInfo, extInterface) - if err != nil { fmt.Printf("+%v", err) t.Fatal(err) diff --git a/network/ovs_networkclient_linux.go b/network/ovs_networkclient_linux.go index bd088b067..3fdaf5afa 100644 --- a/network/ovs_networkclient_linux.go +++ b/network/ovs_networkclient_linux.go @@ -73,7 +73,8 @@ func (client *OVSNetworkClient) AddRoutes(nwInfo *NetworkInfo, interfaceName str } func NewOVSClient(bridgeName, hostInterfaceName string, ovsctlClient ovsctl.OvsInterface, - nl netlink.NetlinkInterface, plc platform.ExecClient) *OVSNetworkClient { + nl netlink.NetlinkInterface, plc platform.ExecClient, +) *OVSNetworkClient { ovsClient := &OVSNetworkClient{ bridgeName: bridgeName, hostInterfaceName: hostInterfaceName, diff --git a/network/ovsinfravnet/infravnet_linux.go b/network/ovsinfravnet/infravnet_linux.go index 093471864..5a2e3ccc7 100644 --- a/network/ovsinfravnet/infravnet_linux.go +++ b/network/ovsinfravnet/infravnet_linux.go @@ -75,8 +75,8 @@ func (client *OVSInfraVnetClient) CreateInfraVnetRules( bridgeName string, infraIP net.IPNet, hostPrimaryMac string, - hostPort string) error { - + hostPort string, +) error { ovs := ovsctl.NewOvsctl() infraContainerPort, err := ovs.GetOVSPortNumber(client.hostInfraVethName) @@ -132,8 +132,8 @@ func (client *OVSInfraVnetClient) ConfigureInfraVnetContainerInterface(infraIP n func (client *OVSInfraVnetClient) DeleteInfraVnetRules( bridgeName string, infraIP net.IPNet, - hostPort string) { - + hostPort string, +) { ovs := ovsctl.NewOvsctl() log.Printf("[ovs] Deleting MAC DNAT rule for infravnet IP address %v", infraIP.IP.String()) diff --git a/network/transparent_endpointclient_linux.go b/network/transparent_endpointclient_linux.go index 17a6d5677..5364443a4 100644 --- a/network/transparent_endpointclient_linux.go +++ b/network/transparent_endpointclient_linux.go @@ -53,7 +53,6 @@ func NewTransparentEndpointClient( nl netlink.NetlinkInterface, plc platform.ExecClient, ) *TransparentEndpointClient { - client := &TransparentEndpointClient{ bridgeName: extIf.BridgeName, hostPrimaryIfName: extIf.Name,