style: Go fumpt entire network package (#1507)

no code changes..so bypassing e2e
This commit is contained in:
QxBytes 2022-08-03 15:09:00 -07:00 коммит произвёл GitHub
Родитель d57e24ee25
Коммит ce14b0b6f5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 18 добавлений и 31 удалений

Просмотреть файл

@ -41,7 +41,6 @@ func NewLinuxBridgeEndpointClient(
nl netlink.NetlinkInterface,
plc platform.ExecClient,
) *LinuxBridgeEndpointClient {
client := &LinuxBridgeEndpointClient{
bridgeName: extIf.BridgeName,
hostPrimaryIfName: extIf.Name,

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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)

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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
}

Просмотреть файл

@ -5,9 +5,10 @@ package hnswrapper
import (
"context"
"time"
"github.com/Microsoft/hcsshim"
"github.com/pkg/errors"
"time"
)
type Hnsv1wrapperwithtimeout struct {

Просмотреть файл

@ -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()

Просмотреть файл

@ -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}
}
}

Просмотреть файл

@ -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)

Просмотреть файл

@ -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,

Просмотреть файл

@ -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())

Просмотреть файл

@ -53,7 +53,6 @@ func NewTransparentEndpointClient(
nl netlink.NetlinkInterface,
plc platform.ExecClient,
) *TransparentEndpointClient {
client := &TransparentEndpointClient{
bridgeName: extIf.BridgeName,
hostPrimaryIfName: extIf.Name,