Skip to content

Commit

Permalink
Address errchkjson linter errchkjson
Browse files Browse the repository at this point in the history
Fix "Error return value of `encoding/json.MarshalIndent` is not checked"

Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis committed Jan 7, 2025
1 parent dbf3384 commit 0e9fc02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions pkg/agent/controller/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package controller

import (
"context"
"encoding/json"
"fmt"
"reflect"
"strconv"
Expand All @@ -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"
Expand Down Expand Up @@ -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)
}
7 changes: 3 additions & 4 deletions pkg/agent/controller/service_endpoint_slices.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package controller

import (
"context"
"encoding/json"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -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)
}

0 comments on commit 0e9fc02

Please sign in to comment.