Skip to content

Commit

Permalink
fix(interface): Remove opts
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptisteFoy committed Jan 19, 2023
1 parent 781a425 commit 103d7d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
31 changes: 5 additions & 26 deletions cmd/trace-agent/remote_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"google.golang.org/grpc"
)

func TestConfigEndpoint(t *testing.T) {
Expand Down Expand Up @@ -55,7 +54,7 @@ func TestConfigEndpoint(t *testing.T) {
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
assert := assert.New(t)
grpc := mockAgentSecureServer{}
grpc := agentGRPCConfigFetcher{}
rcv := api.NewHTTPReceiver(config.New(), sampler.NewDynamicConfig(), make(chan *api.Payload, 5000), nil)
mux := http.NewServeMux()
cfg := &config.AgentConfig{}
Expand Down Expand Up @@ -130,7 +129,7 @@ func TestUpstreamRequest(t *testing.T) {
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
assert := assert.New(t)
grpc := mockAgentSecureServer{}
grpc := agentGRPCConfigFetcher{}
rcv := api.NewHTTPReceiver(config.New(), sampler.NewDynamicConfig(), make(chan *api.Payload, 5000), nil)

var request pbgo.ClientGetConfigsRequest
Expand All @@ -156,32 +155,12 @@ func TestUpstreamRequest(t *testing.T) {
}
}

type mockAgentSecureServer struct {
type agentGRPCConfigFetcher struct {
pbgo.AgentSecureClient
mock.Mock
}

func (a *mockAgentSecureServer) TaggerStreamEntities(ctx context.Context, in *pbgo.StreamTagsRequest, opts ...grpc.CallOption) (pbgo.AgentSecure_TaggerStreamEntitiesClient, error) {
args := a.Called(ctx, in, opts)
return args.Get(0).(pbgo.AgentSecure_TaggerStreamEntitiesClient), args.Error(1)
}

func (a *mockAgentSecureServer) TaggerFetchEntity(ctx context.Context, in *pbgo.FetchEntityRequest, opts ...grpc.CallOption) (*pbgo.FetchEntityResponse, error) {
args := a.Called(ctx, in, opts)
return args.Get(0).(*pbgo.FetchEntityResponse), args.Error(1)
}

func (a *mockAgentSecureServer) DogstatsdCaptureTrigger(ctx context.Context, in *pbgo.CaptureTriggerRequest, opts ...grpc.CallOption) (*pbgo.CaptureTriggerResponse, error) {
args := a.Called(ctx, in, opts)
return args.Get(0).(*pbgo.CaptureTriggerResponse), args.Error(1)
}

func (a *mockAgentSecureServer) DogstatsdSetTaggerState(ctx context.Context, in *pbgo.TaggerState, opts ...grpc.CallOption) (*pbgo.TaggerStateResponse, error) {
args := a.Called(ctx, in, opts)
return args.Get(0).(*pbgo.TaggerStateResponse), args.Error(1)
}

func (a *mockAgentSecureServer) ClientGetConfigs(ctx context.Context, in *pbgo.ClientGetConfigsRequest, opts ...grpc.CallOption) (*pbgo.ClientGetConfigsResponse, error) {
args := a.Called(ctx, in, opts)
func (a *agentGRPCConfigFetcher) ClientGetConfigs(ctx context.Context, in *pbgo.ClientGetConfigsRequest) (*pbgo.ClientGetConfigsResponse, error) {
args := a.Called(ctx, in)
return args.Get(0).(*pbgo.ClientGetConfigsResponse), args.Error(1)
}
6 changes: 3 additions & 3 deletions pkg/config/remote/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
// ConfigUpdater defines the interface that an agent client uses to get config updates
// from the core remote-config service
type ConfigUpdater interface {
ClientGetConfigs(context.Context, *pbgo.ClientGetConfigsRequest, ...grpc.CallOption) (*pbgo.ClientGetConfigsResponse, error)
ClientGetConfigs(context.Context, *pbgo.ClientGetConfigsRequest) (*pbgo.ClientGetConfigsResponse, error)
}

// Client is a remote-configuration client to obtain configurations from the local API
Expand Down Expand Up @@ -93,7 +93,7 @@ func NewAgentGRPCConfigFetcher() (*agentGRPCConfigFetcher, error) {
}

// ClientGetConfigs implements the ConfigUpdater interface for agentGRPCConfigFetcher
func (g *agentGRPCConfigFetcher) ClientGetConfigs(ctx context.Context, request *pbgo.ClientGetConfigsRequest, opts ...grpc.CallOption) (*pbgo.ClientGetConfigsResponse, error) {
func (g *agentGRPCConfigFetcher) ClientGetConfigs(ctx context.Context, request *pbgo.ClientGetConfigsRequest) (*pbgo.ClientGetConfigsResponse, error) {
// When communicating with the core service via grpc, the auth token is handled
// by the core-agent, which runs independently. It's not guaranteed it starts before us,
// or that if it restarts that the auth token remains the same. Thus we need to do this every request.
Expand All @@ -107,7 +107,7 @@ func (g *agentGRPCConfigFetcher) ClientGetConfigs(ctx context.Context, request *

ctx = metadata.NewOutgoingContext(ctx, md)

return g.client.ClientGetConfigs(ctx, request, opts...)
return g.client.ClientGetConfigs(ctx, request)
}

// NewClient creates a new client
Expand Down

0 comments on commit 103d7d5

Please sign in to comment.