Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vardhaman22 committed Aug 10, 2023
1 parent c99b986 commit 07cf7c5
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pkg/aggregation/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (l *Listener) Close() error {
return nil
}

func (l *Listener) Dial(ctx context.Context, network, address string) (net.Conn, error) {
func (l *Listener) Dial(ctx context.Context, _, _ string) (net.Conn, error) {
left, right := net.Pipe()
l.RLock()
defer l.RUnlock()
Expand Down
2 changes: 1 addition & 1 deletion pkg/aggregation/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type handler struct {
cancel func()
}

func (h *handler) OnSecret(key string, secret *corev1.Secret) (*corev1.Secret, error) {
func (h *handler) OnSecret(_ string, secret *corev1.Secret) (*corev1.Secret, error) {
if secret == nil {
return nil, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func ToMiddleware(auth Authenticator) Middleware {
}
}

func AlwaysAdmin(req *http.Request) (user.Info, bool, error) {
func AlwaysAdmin(_ *http.Request) (user.Info, bool, error) {
return &user.DefaultInfo{
Name: "admin",
UID: "admin",
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/schema/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ func Register(ctx context.Context,
crd.OnChange(ctx, "schema", h.OnChangeCRD)
}

func (h *handler) OnChangeCRD(key string, crd *apiextv1.CustomResourceDefinition) (*apiextv1.CustomResourceDefinition, error) {
func (h *handler) OnChangeCRD(_ string, crd *apiextv1.CustomResourceDefinition) (*apiextv1.CustomResourceDefinition, error) {
h.queueRefresh()
return crd, nil
}

func (h *handler) OnChangeAPIService(key string, api *apiv1.APIService) (*apiv1.APIService, error) {
func (h *handler) OnChangeAPIService(_ string, api *apiv1.APIService) (*apiv1.APIService, error) {
h.queueRefresh()
return api, nil
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/podimpersonation/podimpersonation.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ func (s *PodImpersonation) waitForServiceAccount(ctx context.Context, client kub
}
defer func() {
go func() {
for range w.ResultChan() {
for len(w.ResultChan()) > 0 {
<-w.ResultChan()
}
}()
w.Stop()
Expand Down Expand Up @@ -410,7 +411,8 @@ func (s *PodImpersonation) createPod(ctx context.Context, user user.Info, role *
}
defer func() {
go func() {
for range resp.ResultChan() {
for len(resp.ResultChan()) > 0 {
<-resp.ResultChan()
}
}()
resp.Stop()
Expand Down Expand Up @@ -510,7 +512,7 @@ func (s *PodImpersonation) adminKubeConfig(user user.Info, role *rbacv1.ClusterR
}, nil
}

func (s *PodImpersonation) augmentPod(pod *v1.Pod, sa *v1.ServiceAccount, secret *v1.Secret, imageOverride string) *v1.Pod {
func (s *PodImpersonation) augmentPod(pod *v1.Pod, _ *v1.ServiceAccount, secret *v1.Secret, imageOverride string) *v1.Pod {
var (
zero = int64(0)
t = true
Expand Down
2 changes: 1 addition & 1 deletion pkg/proxy/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var (
type errorResponder struct {
}

func (e *errorResponder) Error(w http.ResponseWriter, req *http.Request, err error) {
func (e *errorResponder) Error(w http.ResponseWriter, _ *http.Request, err error) {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
}
2 changes: 1 addition & 1 deletion pkg/resources/apigroups/apigroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func toAPIObject(schema *types.APISchema, group v1.APIGroup) types.APIObject {

}

func (e *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (types.APIObjectList, error) {
func (e *Store) List(_ *types.APIRequest, schema *types.APISchema) (types.APIObjectList, error) {
groupList, err := e.discovery.ServerGroups()
if err != nil {
return types.APIObjectList{}, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/cluster/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Apply struct {
schemaFactory steveschema.Factory
}

func (a *Apply) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
func (a *Apply) ServeHTTP(_ http.ResponseWriter, req *http.Request) {
var (
apiContext = types.GetAPIContext(req.Context())
input ApplyInput
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (s *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (types.AP
}, nil
}

func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest) (chan types.APIEvent, error) {
func (s *Store) Watch(apiOp *types.APIRequest, _ *types.APISchema, _ types.WatchRequest) (chan types.APIEvent, error) {
result := make(chan types.APIEvent, 1)
result <- types.APIEvent{
Name: "local",
Expand Down
6 changes: 3 additions & 3 deletions pkg/resources/counts/counts.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ func toAPIObject(c Count) types.APIObject {
}
}

func (s *Store) ByID(apiOp *types.APIRequest, schema *types.APISchema, id string) (types.APIObject, error) {
func (s *Store) ByID(apiOp *types.APIRequest, _ *types.APISchema, _ string) (types.APIObject, error) {
c := s.getCount(apiOp)
return toAPIObject(c), nil
}

func (s *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (types.APIObjectList, error) {
func (s *Store) List(apiOp *types.APIRequest, _ *types.APISchema) (types.APIObjectList, error) {
c := s.getCount(apiOp)
return types.APIObjectList{
Objects: []types.APIObject{
Expand All @@ -112,7 +112,7 @@ func (s *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (types.AP
}

// Watch creates a watch for the Counts schema. This returns only the counts which have changed since the watch was established
func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest) (chan types.APIEvent, error) {
func (s *Store) Watch(apiOp *types.APIRequest, _ *types.APISchema, _ types.WatchRequest) (chan types.APIEvent, error) {
var (
result = make(chan Count, 100)
counts map[string]ItemCount
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/formatters/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/rancher/norman/types/convert"
)

func DropHelmData(request *types.APIRequest, resource *types.RawResource) {
func DropHelmData(_ *types.APIRequest, resource *types.RawResource) {
data := resource.APIObject.Data()
if data.String("metadata", "labels", "owner") == "helm" ||
data.String("metadata", "labels", "OWNER") == "TILLER" {
Expand All @@ -15,7 +15,7 @@ func DropHelmData(request *types.APIRequest, resource *types.RawResource) {
}
}

func Pod(request *types.APIRequest, resource *types.RawResource) {
func Pod(_ *types.APIRequest, resource *types.RawResource) {
data := resource.APIObject.Data()
fields := data.StringSlice("metadata", "fields")
if len(fields) > 2 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/resources/userpreferences/localpref.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func getUserName(apiOp *types.APIRequest) string {
return user.GetName()
}

func (l *localStore) ByID(apiOp *types.APIRequest, schema *types.APISchema, id string) (types.APIObject, error) {
func (l *localStore) ByID(apiOp *types.APIRequest, _ *types.APISchema, _ string) (types.APIObject, error) {
data, err := get()
if err != nil {
return types.APIObject{}, err
Expand All @@ -90,15 +90,15 @@ func (l *localStore) List(apiOp *types.APIRequest, schema *types.APISchema) (typ
}, nil
}

func (l *localStore) Update(apiOp *types.APIRequest, schema *types.APISchema, data types.APIObject, id string) (types.APIObject, error) {
func (l *localStore) Update(apiOp *types.APIRequest, schema *types.APISchema, data types.APIObject, _ string) (types.APIObject, error) {
err := set(data.Data())
if err != nil {
return types.APIObject{}, err
}
return l.ByID(apiOp, schema, "")
}

func (l *localStore) Delete(apiOp *types.APIRequest, schema *types.APISchema, id string) (types.APIObject, error) {
func (l *localStore) Delete(apiOp *types.APIRequest, schema *types.APISchema, _ string) (types.APIObject, error) {
return l.Update(apiOp, schema, types.APIObject{
Object: map[string]interface{}{},
}, "")
Expand Down
2 changes: 1 addition & 1 deletion pkg/schema/table/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (t *ColumnMapper) FromInternal(d data.Object) {
}
}

func (t *ColumnMapper) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
func (t *ColumnMapper) ModifySchema(schema *types.Schema, _ *types.Schemas) error {
as := &types2.APISchema{
Schema: schema,
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/handler/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/rancher/steve/pkg/schema"
)

func k8sAPI(sf schema.Factory, apiOp *types.APIRequest) {
func k8sAPI(_ schema.Factory, apiOp *types.APIRequest) {
vars := mux.Vars(apiOp.Request)
apiOp.Name = vars["name"]
apiOp.Type = vars["type"]
Expand All @@ -27,6 +27,6 @@ func k8sAPI(sf schema.Factory, apiOp *types.APIRequest) {
}
}

func apiRoot(sf schema.Factory, apiOp *types.APIRequest) {
func apiRoot(_ schema.Factory, apiOp *types.APIRequest) {
apiOp.Type = "apiRoot"
}
2 changes: 1 addition & 1 deletion pkg/stores/partition/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func moveToUnderscore(obj *unstructured.Unstructured) *unstructured.Unstructured
return obj
}

func toAPIEvent(apiOp *types.APIRequest, schema *types.APISchema, event watch.Event) types.APIEvent {
func toAPIEvent(_ *types.APIRequest, schema *types.APISchema, event watch.Event) types.APIEvent {
name := types.ChangeAPIEvent
switch event.Type {
case watch.Deleted:
Expand Down
2 changes: 1 addition & 1 deletion pkg/stores/proxy/proxy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (s *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (*unstruc
return result, buffer, err
}

func (s *Store) list(apiOp *types.APIRequest, schema *types.APISchema, client dynamic.ResourceInterface) (*unstructured.UnstructuredList, error) {
func (s *Store) list(apiOp *types.APIRequest, _ *types.APISchema, client dynamic.ResourceInterface) (*unstructured.UnstructuredList, error) {
opts := metav1.ListOptions{}
if err := decodeParams(apiOp, &opts); err != nil {
return nil, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/stores/proxy/rbac_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type rbacPartitioner struct {

// Lookup returns the default passthrough partition which is used only for retrieving single resources.
// Listing or watching resources require custom partitions.
func (p *rbacPartitioner) Lookup(apiOp *types.APIRequest, schema *types.APISchema, verb, id string) (partition.Partition, error) {
func (p *rbacPartitioner) Lookup(_ *types.APIRequest, _ *types.APISchema, verb, _ string) (partition.Partition, error) {
switch verb {
case "create":
fallthrough
Expand Down Expand Up @@ -88,7 +88,7 @@ func (p *rbacPartitioner) All(apiOp *types.APIRequest, schema *types.APISchema,
}

// Store returns an UnstructuredStore suited to listing and watching resources by partition.
func (p *rbacPartitioner) Store(apiOp *types.APIRequest, partition partition.Partition) (partition.UnstructuredStore, error) {
func (p *rbacPartitioner) Store(_ *types.APIRequest, partition partition.Partition) (partition.UnstructuredStore, error) {
return &byNameOrNamespaceStore{
Store: p.proxyStore,
partition: partition.(Partition),
Expand Down
14 changes: 7 additions & 7 deletions pkg/summarycache/summarycache.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ func (s *SummaryCache) process(obj runtime.Object) (*summary.SummarizedObject, [
if schema == nil {
continue
}
copy := rel
if copy.Namespace == "" && attributes.Namespaced(schema) {
copy.Namespace = summary.Namespace
relCopy := rel
if relCopy.Namespace == "" && attributes.Namespaced(schema) {
relCopy.Namespace = summary.Namespace
}
rels = append(rels, &copy)
rels = append(rels, &relCopy)
}

return summary, rels
Expand Down Expand Up @@ -324,17 +324,17 @@ func (s *SummaryCache) refersTo(summarized *summary.SummarizedObject, rel *summa
return summarized.Namespace == ns
}

func (s *SummaryCache) OnAdd(_ runtimeschema.GroupVersionKind, key string, obj runtime.Object) error {
func (s *SummaryCache) OnAdd(_ runtimeschema.GroupVersionKind, _ string, obj runtime.Object) error {
s.Add(obj)
return nil
}

func (s *SummaryCache) OnRemove(_ runtimeschema.GroupVersionKind, key string, obj runtime.Object) error {
func (s *SummaryCache) OnRemove(_ runtimeschema.GroupVersionKind, _ string, obj runtime.Object) error {
s.Remove(obj)
return nil
}

func (s *SummaryCache) OnChange(_ runtimeschema.GroupVersionKind, key string, obj, oldObj runtime.Object) error {
func (s *SummaryCache) OnChange(_ runtimeschema.GroupVersionKind, _ string, obj, oldObj runtime.Object) error {
s.Change(obj, oldObj)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e
go generate ./..
golangci-lint run --new
golangci-lint run
go mod tidy
go mod verify
unclean=$(git status --porcelain --untracked-files=no)
Expand Down

0 comments on commit 07cf7c5

Please sign in to comment.