Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GolangCI issues causing test failures #1724

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (s *sinker) Start(ctx context.Context) error {

// For handling Liveness Probe
// TODO(dibyom): Livness, metrics etc. should be on a separate port
mux.HandleFunc("/live", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/live", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(200)
fmt.Fprint(w, "ok")
})
Expand Down Expand Up @@ -276,7 +276,7 @@ func (s *sinker) Start(ctx context.Context) error {
}

func New(sinkArgs sink.Args, sinkClients sink.Clients, recorder *sink.Recorder) adapter.AdapterConstructor {
return func(ctx context.Context, processed adapter.EnvConfigAccessor, ceClient cloudevents.Client) adapter.Adapter {
return func(ctx context.Context, processed adapter.EnvConfigAccessor, _ cloudevents.Client) adapter.Adapter {
env := processed.(*envConfig)
logger := logging.FromContext(ctx)

Expand Down
4 changes: 2 additions & 2 deletions pkg/interceptors/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ func TestInterceptor_ExecuteTrigger_Changed_Files_Pull_Request(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, _ *http.Request) {
writer.Write([]byte(tt.githubServerReply))
}))
ctx, _ := test.SetupFakeContext(t)
Expand Down Expand Up @@ -913,7 +913,7 @@ func TestInterceptor_ExecuteTrigger_Changed_Files_Push(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, _ *http.Request) {
writer.Write([]byte(tt.githubServerReply))
}))
ctx, _ := test.SetupFakeContext(t)
Expand Down
4 changes: 2 additions & 2 deletions pkg/interceptors/interceptors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func TestResolveToURL(t *testing.T) {
want string
}{{
name: "ClusterInterceptor has status.address.url",
getter: func(n string) (*v1alpha1.ClusterInterceptor, error) {
getter: func(_ string) (*v1alpha1.ClusterInterceptor, error) {
return &v1alpha1.ClusterInterceptor{
Status: v1alpha1.ClusterInterceptorStatus{
AddressStatus: duckv1.AddressStatus{
Expand Down Expand Up @@ -338,7 +338,7 @@ func TestResolveToURL(t *testing.T) {
}

t.Run("interceptor has no URL", func(t *testing.T) {
fakeGetter := func(name string) (*v1alpha1.ClusterInterceptor, error) {
fakeGetter := func(_ string) (*v1alpha1.ClusterInterceptor, error) {
return &v1alpha1.ClusterInterceptor{
Spec: v1alpha1.ClusterInterceptorSpec{
ClientConfig: v1alpha1.ClientConfig{
Expand Down
2 changes: 1 addition & 1 deletion pkg/interceptors/webhook/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestWebHookInterceptor_NotOK(t *testing.T) {
})

// Create test server
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusAccepted)
}))
defer ts.Close()
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/clusterinterceptor/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (
)

func NewController() func(context.Context, configmap.Watcher) *controller.Impl {
return func(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
return func(ctx context.Context, _ configmap.Watcher) *controller.Impl {
clusterInterceptorInformer := clusterinterceptorinformer.Get(ctx)
reconciler := &Reconciler{}

impl := clusterinterceptorreconciler.NewImpl(ctx, reconciler, func(impl *controller.Impl) controller.Options {
impl := clusterinterceptorreconciler.NewImpl(ctx, reconciler, func(_ *controller.Impl) controller.Options {
return controller.Options{
AgentName: ControllerName,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/eventlistener/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NewController(config resources.Config) func(context.Context, configmap.Watc
Metrics: metrics.Get(ctx),
}

impl := eventlistenerreconciler.NewImpl(ctx, reconciler, func(impl *controller.Impl) controller.Options {
impl := eventlistenerreconciler.NewImpl(ctx, reconciler, func(_ *controller.Impl) controller.Options {
configStore := cfg.NewStore(logger.Named("config-store"))
configStore.WatchConfigs(cmw)
return controller.Options{
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/interceptor/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (
)

func NewController() func(context.Context, configmap.Watcher) *controller.Impl {
return func(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
return func(ctx context.Context, _ configmap.Watcher) *controller.Impl {
interceptorInformer := interceptorinformer.Get(ctx)
reconciler := &Reconciler{}

impl := interceptorreconciler.NewImpl(ctx, reconciler, func(impl *controller.Impl) controller.Options {
impl := interceptorreconciler.NewImpl(ctx, reconciler, func(_ *controller.Impl) controller.Options {
return controller.Options{
AgentName: ControllerName,
}
Expand Down
2 changes: 1 addition & 1 deletion test/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type Assets struct {

func init() {
// Register a separate fake dynamic client with out schemes.
injection.Fake.RegisterClient(func(ctx context.Context, cfg *rest.Config) context.Context {
injection.Fake.RegisterClient(func(ctx context.Context, _ *rest.Config) context.Context {
scheme := runtime.NewScheme()
err := servingv1.AddToScheme(scheme)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion test/gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func FeatureFlagsToContext(ctx context.Context, flags map[string]string) (contex
// the feature-flag configmap.
// nolint:unused,deadcode
func requireGate(name, value string) func(context.Context, *testing.T, *clients, string) {
return func(ctx context.Context, t *testing.T, c *clients, namespace string) {
return func(ctx context.Context, t *testing.T, c *clients, _ string) {
featureFlagsCM, err := c.KubeClient.CoreV1().ConfigMaps(system.Namespace()).Get(ctx, config.GetFeatureFlagsConfigName(), metav1.GetOptions{})
if err != nil {
t.Fatalf("Failed to get ConfigMap `%s`: %s", config.GetFeatureFlagsConfigName(), err)
Expand Down
2 changes: 1 addition & 1 deletion test/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func verifyDefaultServiceAccountExists(t *testing.T, namespace string, kubeClien

func getCRDYaml(cs *clients, ns string) ([]byte, error) {
var output []byte
printOrAdd := func(kind, name string, i interface{}) {
printOrAdd := func(_, _ string, i interface{}) {
bs, err := json.Marshal(i)
if err != nil {
return
Expand Down