Ver Fonte

pass by ptr to pass govet

Signed-off-by: Alex Meijer <ameijer@kubecost.com>
Alex Meijer há 2 anos atrás
pai
commit
ae4ca8a130
2 ficheiros alterados com 8 adições e 8 exclusões
  1. 7 7
      core/pkg/plugin/grpc.go
  2. 1 1
      core/pkg/plugin/plugin_interface.go

+ 7 - 7
core/pkg/plugin/grpc.go

@@ -9,18 +9,18 @@ import (
 // GRPCClient is an implementation of CustomCostsSource that talks over RPC.
 type GRPCClient struct{ client pb.CustomCostsSourceClient }
 
-func (m *GRPCClient) GetCustomCosts(req pb.CustomCostRequest) []pb.CustomCostResponse {
-	resp, err := m.client.GetCustomCosts(context.Background(), &req)
+func (m *GRPCClient) GetCustomCosts(req *pb.CustomCostRequest) []*pb.CustomCostResponse {
+	resp, err := m.client.GetCustomCosts(context.Background(), req)
 	if err != nil {
-		return []pb.CustomCostResponse{
+		return []*pb.CustomCostResponse{
 			{
 				Errors: []string{err.Error()},
 			},
 		}
 	}
-	derefs := []pb.CustomCostResponse{}
+	derefs := []*pb.CustomCostResponse{}
 	for _, resp := range resp.Resps {
-		derefs = append(derefs, *resp)
+		derefs = append(derefs, resp)
 	}
 	return derefs
 }
@@ -36,9 +36,9 @@ func (m *GRPCServer) GetCustomCosts(
 	ctx context.Context,
 	req *pb.CustomCostRequest) (*pb.CustomCostResponseSet, error) {
 	ptrs := []*pb.CustomCostResponse{}
-	costs := m.Impl.GetCustomCosts(*req)
+	costs := m.Impl.GetCustomCosts(req)
 	for _, cost := range costs {
-		ptrs = append(ptrs, &cost)
+		ptrs = append(ptrs, cost)
 	}
 	return &pb.CustomCostResponseSet{
 		Resps: ptrs,

+ 1 - 1
core/pkg/plugin/plugin_interface.go

@@ -10,7 +10,7 @@ import (
 
 // plugin interface
 type CustomCostSource interface {
-	GetCustomCosts(req pb.CustomCostRequest) []pb.CustomCostResponse
+	GetCustomCosts(req *pb.CustomCostRequest) []*pb.CustomCostResponse
 }
 
 type CustomCostPlugin struct {