Skip to content

Commit 45f3668

Browse files
authored
chore: appease the linter, pt 1 of ? (#922)
1 parent a0e322d commit 45f3668

File tree

21 files changed

+145
-170
lines changed

21 files changed

+145
-170
lines changed

cni/network/network.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,8 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) error {
674674
}
675675

676676
epPolicies := getPoliciesFromRuntimeCfg(nwCfg)
677-
for _, epPolicy := range epPolicies {
678-
epInfo.Policies = append(epInfo.Policies, epPolicy)
679-
}
677+
678+
epInfo.Policies = append(epInfo.Policies, epPolicies...)
680679

681680
// Populate addresses.
682681
for _, ipconfig := range result.IPs {

cnm/plugin/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func main() {
207207

208208
// Relay these incoming signals to OS signal channel.
209209
osSignalChannel := make(chan os.Signal, 1)
210-
signal.Notify(osSignalChannel, os.Interrupt, os.Kill, syscall.SIGTERM)
210+
signal.Notify(osSignalChannel, os.Interrupt, syscall.SIGTERM)
211211

212212
// Wait until receiving a signal.
213213
select {

cnms/service/networkmonitor.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func main() {
139139
tb.ConnectToTelemetryService(telemetryNumRetries, telemetryWaitTimeInMilliseconds)
140140
defer tb.Close()
141141

142-
for true {
142+
for {
143143
config.Store, err = store.NewJsonFileStore(platform.CNIRuntimePath + pluginName + ".json")
144144
if err != nil {
145145
fmt.Printf("[monitor] Failed to create store: %v\n", err)
@@ -178,6 +178,4 @@ func main() {
178178
time.Sleep(time.Duration(timeout) * time.Second)
179179
nm = nil
180180
}
181-
182-
log.Close()
183181
}

cns/service/main.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const (
4848
name = "azure-cns"
4949
pluginName = "azure-vnet"
5050
defaultCNINetworkConfigFileName = "10-azure.conflist"
51-
configFileName = "config.json"
5251
dncApiVersion = "?api-version=2018-03-01"
5352
poolIPAMRefreshRateInMilliseconds = 1000
5453

@@ -321,19 +320,14 @@ func sendRegisterNodeRequest(
321320
nodeRegisterRequest cns.NodeRegisterRequest,
322321
registerURL string) (bool, error) {
323322

324-
var (
325-
body bytes.Buffer
326-
response *http.Response
327-
err = fmt.Errorf("")
328-
)
329-
330-
err = json.NewEncoder(&body).Encode(nodeRegisterRequest)
323+
var body bytes.Buffer
324+
err := json.NewEncoder(&body).Encode(nodeRegisterRequest)
331325
if err != nil {
332326
log.Errorf("[Azure CNS] Failed to register node while encoding json failed with non-retriable err %v", err)
333327
return false, err
334328
}
335329

336-
response, err = httpc.Post(registerURL, "application/json", &body)
330+
response, err := httpc.Post(registerURL, "application/json", &body)
337331
if err != nil {
338332
logger.Errorf("[Azure CNS] Failed to register node with retriable err: %+v", err)
339333
return false, nil
@@ -610,10 +604,8 @@ func main() {
610604
// Periodically poll DNC for node updates
611605
tickerChannel := time.Tick(time.Duration(cnsconfig.ManagedSettings.NodeSyncIntervalInSeconds) * time.Second)
612606
for {
613-
select {
614-
case <-tickerChannel:
615-
httpRestService.SyncNodeStatus(ep, vnet, node, json.RawMessage{})
616-
}
607+
<-tickerChannel
608+
httpRestService.SyncNodeStatus(ep, vnet, node, json.RawMessage{})
617609
}
618610
}(privateEndpoint, infravnet, nodeID)
619611
}

network/bridge_endpointclient_linux.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ func NewLinuxBridgeEndpointClient(
4444
mode: mode,
4545
}
4646

47-
for _, ipAddr := range extIf.IPAddresses {
48-
client.hostIPAddresses = append(client.hostIPAddresses, ipAddr)
49-
}
47+
client.hostIPAddresses = append(client.hostIPAddresses, extIf.IPAddresses...)
5048

5149
return client
5250
}

network/endpoint.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,9 @@ func (ep *endpoint) getInfo() *EndpointInfo {
218218
NetworkContainerID: ep.NetworkContainerID,
219219
}
220220

221-
for _, route := range ep.Routes {
222-
info.Routes = append(info.Routes, route)
223-
}
221+
info.Routes = append(info.Routes, ep.Routes...)
224222

225-
for _, gw := range ep.Gateways {
226-
info.Gateways = append(info.Gateways, gw)
227-
}
223+
info.Gateways = append(info.Gateways, ep.Gateways...)
228224

229225
// Call the platform implementation.
230226
ep.getInfoImpl(info)

network/endpoint_linux.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,7 @@ func (nw *network) newEndpointImpl(epInfo *EndpointInfo) (*endpoint, error) {
211211
PODNameSpace: epInfo.PODNameSpace,
212212
}
213213

214-
for _, route := range epInfo.Routes {
215-
ep.Routes = append(ep.Routes, route)
216-
}
217-
214+
ep.Routes = append(ep.Routes, epInfo.Routes...)
218215
return ep, nil
219216
}
220217

@@ -381,9 +378,7 @@ func (nw *network) updateEndpointImpl(existingEpInfo *EndpointInfo, targetEpInfo
381378
}
382379

383380
// Update existing endpoint state with the new routes to persist
384-
for _, route := range targetEpInfo.Routes {
385-
ep.Routes = append(ep.Routes, route)
386-
}
381+
ep.Routes = append(ep.Routes, targetEpInfo.Routes...)
387382

388383
return ep, nil
389384
}

network/epcommon/endpoint_common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func BlockIPAddresses(bridgeName string, action string) error {
189189
func EnableIPForwarding(ifName string) error {
190190
// Enable ip forwading on linux vm.
191191
// sysctl -w net.ipv4.ip_forward=1
192-
cmd := fmt.Sprintf(enableIPForwardCmd)
192+
cmd := fmt.Sprint(enableIPForwardCmd)
193193
_, err := platform.ExecuteCommand(cmd)
194194
if err != nil {
195195
log.Printf("[net] Enable ipforwarding failed with: %v", err)
@@ -206,7 +206,7 @@ func EnableIPForwarding(ifName string) error {
206206
}
207207

208208
func EnableIPV6Forwarding() error {
209-
cmd := fmt.Sprintf(enableIPV6ForwardCmd)
209+
cmd := fmt.Sprint(enableIPV6ForwardCmd)
210210
_, err := platform.ExecuteCommand(cmd)
211211
if err != nil {
212212
log.Printf("[net] Enable ipv6 forwarding failed with: %v", err)

network/manager.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const (
2727
)
2828

2929
var (
30-
Ipv4DefaultRouteDstPrefix = net.IPNet{net.IPv4zero, net.IPv4Mask(0, 0, 0, 0)}
30+
Ipv4DefaultRouteDstPrefix = net.IPNet{
31+
IP: net.IPv4zero,
32+
Mask: net.IPv4Mask(0, 0, 0, 0),
33+
}
3134
)
3235

3336
type NetworkClient interface {

network/network_linux.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ func (nm *networkManager) newNetworkImpl(nwInfo *NetworkInfo, extIf *externalInt
6868
handleCommonOptions(extIf.BridgeName, nwInfo)
6969
case opModeTransparent:
7070
handleCommonOptions(extIf.Name, nwInfo)
71-
break
7271
default:
7372
return nil, errNetworkModeInvalid
7473
}

0 commit comments

Comments
 (0)