Skip to content

Commit ec6c555

Browse files
committed
lint: fix checks for the json encoding function.
1 parent 9881385 commit ec6c555

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

.golangci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ linters:
1818
- dupword
1919
- durationcheck
2020
- errcheck
21-
# - errchkjson
21+
- errchkjson
2222
- exportloopref
2323
- gci
2424
# - ginkgolinter
@@ -54,6 +54,8 @@ linters:
5454
- whitespace
5555

5656
linters-settings:
57+
errchkjson:
58+
check-error-free-encoding: true
5759
gci:
5860
local-prefixes: "sigs.k8s.io/cluster-api-provider-vsphere"
5961
godot:

pkg/services/vmoperator/vmopmachine.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,7 @@ func addVolumes(ctx *vmware.SupervisorMachineContext, vm *vmoprv1.VirtualMachine
476476
topology := []map[string]string{
477477
{kubeTopologyZoneLabelKey: *zone},
478478
}
479-
b, err := json.Marshal(topology)
480-
if err != nil {
481-
return errors.Errorf("failed to marshal zone topology %q: %s", *zone, err)
482-
}
479+
b, _ := json.Marshal(topology)
483480
pvc.Annotations = map[string]string{
484481
"csi.vsphere.volume-requested-topology": string(b),
485482
}

test/integration/integration_suite_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ func generateVirtualMachineImage() *vmoprv1.VirtualMachineImage {
325325
},
326326
}
327327

328-
rawJSON, err := json.Marshal(spec)
329-
Expect(err).NotTo(HaveOccurred())
328+
rawJSON, _ := json.Marshal(spec)
330329

331330
annotations[VirtualMachineDistributionProperty] = string(rawJSON)
332331

0 commit comments

Comments
 (0)