From e6852a5047b0a952257284afb5b283f1a22afd63 Mon Sep 17 00:00:00 2001 From: Alan Greene Date: Wed, 19 Apr 2023 12:45:26 +0100 Subject: [PATCH] Fix golang lint issues The version and rules in the testrunner image have been updated. Resolve the new issues identified. --- pkg/csrf/csrf.go | 4 ++-- pkg/endpoints/cluster.go | 2 +- pkg/endpoints/health.go | 4 ++-- pkg/router/router.go | 14 +++++--------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pkg/csrf/csrf.go b/pkg/csrf/csrf.go index 8d4d84d5b..4115eafba 100644 --- a/pkg/csrf/csrf.go +++ b/pkg/csrf/csrf.go @@ -1,5 +1,5 @@ /* -Copyright 2021-2022 The Tekton Authors +Copyright 2021-2023 The Tekton Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -74,7 +74,7 @@ func (cs *csrf) ServeHTTP(w http.ResponseWriter, r *http.Request) { cs.h.ServeHTTP(w, r) } -func unauthorizedHandler(w http.ResponseWriter, r *http.Request) { +func unauthorizedHandler(w http.ResponseWriter, _ *http.Request) { http.Error(w, fmt.Sprintf("%s - %s", http.StatusText(http.StatusForbidden), errorNoHeader), http.StatusForbidden) diff --git a/pkg/endpoints/cluster.go b/pkg/endpoints/cluster.go index 150daafee..d6c31f25b 100644 --- a/pkg/endpoints/cluster.go +++ b/pkg/endpoints/cluster.go @@ -38,7 +38,7 @@ type Properties struct { // GetProperties is used to get the installed namespace for the Dashboard, // the version of the Tekton Dashboard, the version of Tekton Pipelines, // when one's in read-only mode and Tekton Triggers version (if Installed) -func (r Resource) GetProperties(response http.ResponseWriter, request *http.Request) { +func (r Resource) GetProperties(response http.ResponseWriter, _ *http.Request) { pipelineNamespace := r.Options.GetPipelinesNamespace() triggersNamespace := r.Options.GetTriggersNamespace() dashboardVersion := r.GetDashboardVersion() diff --git a/pkg/endpoints/health.go b/pkg/endpoints/health.go index 46f327a2d..7616fd00b 100644 --- a/pkg/endpoints/health.go +++ b/pkg/endpoints/health.go @@ -1,5 +1,5 @@ /* -Copyright 2019-2022 The Tekton Authors +Copyright 2019-2023 The Tekton Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -18,7 +18,7 @@ import ( ) // CheckHealth responds with a status code 200 signalling that the application can receive requests -func (r Resource) CheckHealth(response http.ResponseWriter, request *http.Request) { +func (r Resource) CheckHealth(response http.ResponseWriter, _ *http.Request) { // A method here so there's scope for doing anything fancy e.g. checking anything else response.WriteHeader(http.StatusOK) } diff --git a/pkg/router/router.go b/pkg/router/router.go index 1edc0c209..f8991c7e6 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -92,7 +92,7 @@ type Server struct { type responder struct{} -func (r *responder) Error(w http.ResponseWriter, req *http.Request, err error) { +func (r *responder) Error(w http.ResponseWriter, _ *http.Request, err error) { logging.Log.Errorf("Error while proxying request: %v", err) http.Error(w, err.Error(), http.StatusInternalServerError) } @@ -126,17 +126,13 @@ func Register(r endpoints.Resource, cfg *rest.Config) (*Server, error) { logging.Log.Info("Adding Kube API") apiProxyPrefix := "/api/" apisProxyPrefix := "/apis/" - proxyHandlerAPI, err := NewProxyHandler(apiProxyPrefix, cfg, 30*time.Second) - if err != nil { - return nil, err - } - proxyHandlerAPIs, err := NewProxyHandler(apisProxyPrefix, cfg, 30*time.Second) + proxyHandler, err := NewProxyHandler(cfg, 30*time.Second) if err != nil { return nil, err } mux := http.NewServeMux() - mux.Handle(apiProxyPrefix, proxyHandlerAPI) - mux.Handle(apisProxyPrefix, proxyHandlerAPIs) + mux.Handle(apiProxyPrefix, proxyHandler) + mux.Handle(apisProxyPrefix, proxyHandler) logging.Log.Info("Adding Dashboard APIs") registerWeb(r, mux) @@ -149,7 +145,7 @@ func Register(r endpoints.Resource, cfg *rest.Config) (*Server, error) { } // NewProxyHandler creates an API proxy handler for the cluster -func NewProxyHandler(apiProxyPrefix string, cfg *rest.Config, keepalive time.Duration) (http.Handler, error) { +func NewProxyHandler(cfg *rest.Config, keepalive time.Duration) (http.Handler, error) { host := cfg.Host if !strings.HasSuffix(host, "/") { host += "/"