Skip to content

Commit

Permalink
Fix GolangCI issues causing test failures
Browse files Browse the repository at this point in the history
This fixes some of the golangci issues which are causing test failures
after upgrading tests to go1.22
  • Loading branch information
khrm authored and tekton-robot committed May 2, 2024
1 parent 9b47289 commit 759eb7b
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
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

0 comments on commit 759eb7b

Please sign in to comment.