Skip to content

Commit 96bec09

Browse files
authored
chore: appease the linter (3/?), the big gofumpt (#987)
* gofumpt -w -s . * small addtl cleanups after gofumpt * rerun after rebase
1 parent 8a60ff1 commit 96bec09

File tree

122 files changed

+2645
-2755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+2645
-2755
lines changed

aitelemetry/telemetrywrapper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func getMetadata(th *telemetryHandle) {
9696
return
9797
}
9898

99-
//acquire write lock before writing metadata to telemetry handle
99+
// acquire write lock before writing metadata to telemetry handle
100100
th.rwmutex.Lock()
101101
th.metadata = metadata
102102
th.rwmutex.Unlock()
@@ -188,7 +188,7 @@ func (th *telemetryHandle) TrackLog(report Report) {
188188
// Initialize new trace message
189189
trace := appinsights.NewTraceTelemetry(report.Message, appinsights.Warning)
190190

191-
//Override few of existing columns with metadata
191+
// Override few of existing columns with metadata
192192
trace.Tags.User().SetAuthUserId(runtime.GOOS)
193193
trace.Tags.Operation().SetId(report.Context)
194194
trace.Tags.Operation().SetParentId(th.appVersion)

aitelemetry/telemetrywrapper_windows.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@ import (
55
"path/filepath"
66
)
77

8-
var (
9-
metadataFile = filepath.FromSlash(os.Getenv("TEMP")) + "\\azuremetadata.json"
10-
)
8+
var metadataFile = filepath.FromSlash(os.Getenv("TEMP")) + "\\azuremetadata.json"

cni/client/client_integration_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,4 @@ func TestGetStateWithEmptyStateFile(t *testing.T) {
104104
state, err := c.GetEndpointState()
105105
require.NoError(t, err)
106106
require.Exactly(t, 0, len(state.ContainerInterfaces))
107-
108107
}

cni/ipam/ipam_test.go

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,20 @@ import (
2121
"github.com/Azure/azure-container-networking/common"
2222
)
2323

24-
var ipamQueryUrl = "localhost:42424"
25-
var ipamQueryResponse = "" +
26-
"<Interfaces>" +
27-
" <Interface MacAddress=\"*\" IsPrimary=\"true\">" +
28-
" <IPSubnet Prefix=\"10.0.0.0/16\">" +
29-
" <IPAddress Address=\"10.0.0.4\" IsPrimary=\"true\"/>" +
30-
" <IPAddress Address=\"10.0.0.5\" IsPrimary=\"false\"/>" +
31-
" <IPAddress Address=\"10.0.0.6\" IsPrimary=\"false\"/>" +
32-
" <IPAddress Address=\"10.0.0.7\" IsPrimary=\"false\"/>" +
33-
" </IPSubnet>" +
34-
" </Interface>" +
35-
"</Interfaces>"
24+
var (
25+
ipamQueryUrl = "localhost:42424"
26+
ipamQueryResponse = "" +
27+
"<Interfaces>" +
28+
" <Interface MacAddress=\"*\" IsPrimary=\"true\">" +
29+
" <IPSubnet Prefix=\"10.0.0.0/16\">" +
30+
" <IPAddress Address=\"10.0.0.4\" IsPrimary=\"true\"/>" +
31+
" <IPAddress Address=\"10.0.0.5\" IsPrimary=\"false\"/>" +
32+
" <IPAddress Address=\"10.0.0.6\" IsPrimary=\"false\"/>" +
33+
" <IPAddress Address=\"10.0.0.7\" IsPrimary=\"false\"/>" +
34+
" </IPSubnet>" +
35+
" </Interface>" +
36+
"</Interfaces>"
37+
)
3638

3739
func TestIpam(t *testing.T) {
3840
RegisterFailHandler(Fail)
@@ -73,11 +75,11 @@ var (
7375
err error
7476
endpointID1 = uuid.New().String()
7577

76-
//this usedAddresses map is to test not duplicate IP's
78+
// this usedAddresses map is to test not duplicate IP's
7779
// have been provided throughout this test execution
7880
UsedAddresses = map[string]string{}
7981

80-
//below is the network,used to test if the IP's provided by IPAM
82+
// below is the network,used to test if the IP's provided by IPAM
8183
// is in the the space requested.
8284
network = net.IPNet{IP: net.ParseIP("10.0.0.0"), Mask: net.CIDRMask(16, 32)}
8385

@@ -104,9 +106,7 @@ var (
104106
})
105107

106108
_ = Describe("Test IPAM", func() {
107-
108109
Context("IPAM start", func() {
109-
110110
var config common.PluginConfig
111111

112112
It("Create IPAM plugin", func() {
@@ -127,7 +127,6 @@ var (
127127
})
128128

129129
Describe("Test IPAM ADD and DELETE pool", func() {
130-
131130
var result *cniTypesCurr.Result
132131

133132
Context("When ADD with nothing, call for ipam triggering request pool and address", func() {
@@ -153,7 +152,6 @@ var (
153152
Expect(err).ShouldNot(HaveOccurred())
154153

155154
delete(UsedAddresses, result.IPs[0].Address.IP.String())
156-
157155
})
158156
})
159157

@@ -167,7 +165,6 @@ var (
167165
})
168166

169167
Describe("Test IPAM ADD and DELETE address", func() {
170-
171168
Context("When address is given", func() {
172169
It("Request pool and address successfully", func() {
173170
arg.StdinData = getStdinData("0.4.0", "", "10.0.0.6")
@@ -217,14 +214,13 @@ var (
217214

218215
AssertProperAddressSpace(result.IPs[0].Address)
219216

220-
//release the container ID for next test
217+
// release the container ID for next test
221218
arg.ContainerID = ""
222219
})
223220
})
224221
})
225222

226223
Describe("Test IPAM DELETE", func() {
227-
228224
Context("Delete when only container id is given", func() {
229225
It("Deleted", func() {
230226
arg.StdinData = getStdinData("0.4.0", "10.0.0.0/16", "")
@@ -236,13 +232,11 @@ var (
236232
address := UsedAddresses[arg.ContainerID]
237233

238234
RemoveAddressUsage(address, arg.ContainerID)
239-
240235
})
241236
})
242237

243238
Context("When address and subnet is given", func() {
244239
It("Release address successfully", func() {
245-
246240
nextAddress := GetNextAddress()
247241
arg.StdinData = getStdinData("0.4.0", "10.0.0.0/16", nextAddress)
248242
err = plugin.Delete(arg)
@@ -291,15 +285,15 @@ var (
291285
)
292286

293287
func GetNextAddress() string {
294-
//return first value
288+
// return first value
295289
for a := range UsedAddresses {
296290
return a
297291
}
298292
return ""
299293
}
300294

301295
func AssertAddressNotInUse(address string) {
302-
//confirm if IP is in use by other invocation
296+
// confirm if IP is in use by other invocation
303297
_, exists := UsedAddresses[address]
304298

305299
Expect(exists).Should(BeFalse())
@@ -325,7 +319,7 @@ func RemoveAddressUsage(address, containerId string) {
325319
}
326320

327321
func AssertProperAddressSpace(address net.IPNet) {
328-
//validate the IP is part of this network IP space
322+
// validate the IP is part of this network IP space
329323
Expect(network.Contains(address.IP)).Should(Equal(true))
330324
Expect(address.Mask).Should(Equal(network.Mask))
331325
}

cni/netconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type PortMapping struct {
2828
Protocol string `json:"protocol"`
2929
HostIp string `json:"hostIP,omitempty"`
3030
}
31+
3132
type RuntimeConfig struct {
3233
PortMappings []PortMapping `json:"portMappings,omitempty"`
3334
DNS RuntimeDNSConfig `json:"dns,omitempty"`

cni/network/invoker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313
// or simply act as a client to an external ipam, such as azure-cns.
1414
type IPAMInvoker interface {
1515

16-
//Add returns two results, one IPv4, the other IPv6.
16+
// Add returns two results, one IPv4, the other IPv6.
1717
Add(nwCfg *cni.NetworkConfig, args *cniSkel.CmdArgs, subnetPrefix *net.IPNet, options map[string]interface{}) (*cniTypesCurr.Result, *cniTypesCurr.Result, error)
1818

19-
//Delete calls to the invoker source, and returns error. Returning an error here will fail the CNI Delete call.
19+
// Delete calls to the invoker source, and returns error. Returning an error here will fail the CNI Delete call.
2020
Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, args *cniSkel.CmdArgs, options map[string]interface{}) error
2121
}

cni/network/invoker_azure.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (invoker *AzureIPAMInvoker) Add(nwCfg *cni.NetworkConfig, _ *cniSkel.CmdArg
4545
result, err = invoker.plugin.DelegateAdd(nwCfg.Ipam.Type, nwCfg)
4646
if err != nil {
4747
err = invoker.plugin.Errorf("Failed to allocate pool: %v", err)
48-
return nil, nil, err
48+
return nil, nil, err
4949
}
5050

5151
defer func() {
@@ -83,7 +83,6 @@ func (invoker *AzureIPAMInvoker) Add(nwCfg *cni.NetworkConfig, _ *cniSkel.CmdArg
8383
}
8484

8585
func (invoker *AzureIPAMInvoker) Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, _ *cniSkel.CmdArgs, options map[string]interface{}) error {
86-
8786
if nwCfg == nil {
8887
return invoker.plugin.Errorf("nil nwCfg passed to CNI ADD, stack: %+v", string(debug.Stack()))
8988
}

cni/network/invoker_cns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func NewCNSInvoker(podName, namespace string) (*CNSIPAMInvoker, error) {
4848
}, err
4949
}
5050

51-
//Add uses the requestipconfig API in cns, and returns ipv4 and a nil ipv6 as CNS doesn't support IPv6 yet
51+
// Add uses the requestipconfig API in cns, and returns ipv4 and a nil ipv6 as CNS doesn't support IPv6 yet
5252
func (invoker *CNSIPAMInvoker) Add(nwCfg *cni.NetworkConfig, args *cniSkel.CmdArgs, hostSubnetPrefix *net.IPNet, options map[string]interface{}) (*cniTypesCurr.Result, *cniTypesCurr.Result, error) {
5353
// Parse Pod arguments.
5454
podInfo := cns.KubernetesPodInfo{

cni/network/network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ func determineSnat() (bool, bool, error) {
12011201
}
12021202

12031203
jsonStr, _ := json.Marshal(snatConfig)
1204-
fp, err := os.OpenFile(snatConfigFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.FileMode(0664))
1204+
fp, err := os.OpenFile(snatConfigFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.FileMode(0o664))
12051205
if err == nil {
12061206
fp.Write(jsonStr)
12071207
fp.Close()

cni/network/network_windows.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ var (
2929
win1903Version = 18362
3030
)
3131

32-
33-
3432
/* handleConsecutiveAdd handles consecutive add calls for infrastructure containers on Windows platform.
3533
* This is a temporary work around for issue #57253 of Kubernetes.
3634
* We can delete this if statement once they fix it.
@@ -289,9 +287,7 @@ func getPoliciesFromRuntimeCfg(nwCfg *cni.NetworkConfig) []policy.Policy {
289287
}
290288

291289
func addIPV6EndpointPolicy(nwInfo network.NetworkInfo) (policy.Policy, error) {
292-
var (
293-
eppolicy policy.Policy
294-
)
290+
var eppolicy policy.Policy
295291

296292
if len(nwInfo.Subnets) < 2 {
297293
return eppolicy, fmt.Errorf("network state doesn't have ipv6 subnet")

0 commit comments

Comments
 (0)