From 0e9fc0292429351faabc717931b2bb86122d8100 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Tue, 7 Jan 2025 08:49:25 -0500 Subject: [PATCH] Address errchkjson linter errchkjson Fix "Error return value of `encoding/json.MarshalIndent` is not checked" Signed-off-by: Tom Pantelis --- pkg/agent/controller/agent.go | 5 ++--- pkg/agent/controller/service_endpoint_slices.go | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/agent/controller/agent.go b/pkg/agent/controller/agent.go index ab276be1..18be60e3 100644 --- a/pkg/agent/controller/agent.go +++ b/pkg/agent/controller/agent.go @@ -20,7 +20,6 @@ package controller import ( "context" - "encoding/json" "fmt" "reflect" "strconv" @@ -29,6 +28,7 @@ import ( "github.com/submariner-io/admiral/pkg/federate" "github.com/submariner-io/admiral/pkg/ipam" "github.com/submariner-io/admiral/pkg/log" + "github.com/submariner-io/admiral/pkg/resource" "github.com/submariner-io/admiral/pkg/syncer" "github.com/submariner-io/admiral/pkg/syncer/broker" "github.com/submariner-io/lighthouse/pkg/constants" @@ -496,6 +496,5 @@ type serviceImportStringer struct { } func (s serviceImportStringer) String() string { - spec, _ := json.MarshalIndent(&s.Spec, "", " ") - return "spec: " + string(spec) + return "spec: " + resource.ToJSON(&s.Spec) } diff --git a/pkg/agent/controller/service_endpoint_slices.go b/pkg/agent/controller/service_endpoint_slices.go index e7e977f3..4700b8a8 100644 --- a/pkg/agent/controller/service_endpoint_slices.go +++ b/pkg/agent/controller/service_endpoint_slices.go @@ -20,7 +20,6 @@ package controller import ( "context" - "encoding/json" "fmt" "strconv" "strings" @@ -380,9 +379,9 @@ type endpointSliceStringer struct { } func (s endpointSliceStringer) String() string { - labels, _ := json.MarshalIndent(&s.Labels, "", " ") - ports, _ := json.MarshalIndent(&s.Ports, "", " ") - endpoints, _ := json.MarshalIndent(&s.Endpoints, "", " ") + labels := resource.ToJSON(&s.Labels) + ports := resource.ToJSON(&s.Ports) + endpoints := resource.ToJSON(&s.Endpoints) return fmt.Sprintf("\nlabels: %s\naddressType: %s\nendpoints: %s\nports: %s", labels, s.AddressType, endpoints, ports) }