Skip to content

Commit cedffe3

Browse files
committed
fix linting issues
1 parent c33f445 commit cedffe3

File tree

18 files changed

+36
-34
lines changed

18 files changed

+36
-34
lines changed

pkg/aggregation/listener.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (l *Listener) Close() error {
4949
return nil
5050
}
5151

52-
func (l *Listener) Dial(ctx context.Context, network, address string) (net.Conn, error) {
52+
func (l *Listener) Dial(ctx context.Context, _, _ string) (net.Conn, error) {
5353
left, right := net.Pipe()
5454
l.RLock()
5555
defer l.RUnlock()

pkg/aggregation/watch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type handler struct {
3434
cancel func()
3535
}
3636

37-
func (h *handler) OnSecret(key string, secret *corev1.Secret) (*corev1.Secret, error) {
37+
func (h *handler) OnSecret(_ string, secret *corev1.Secret) (*corev1.Secret, error) {
3838
if secret == nil {
3939
return nil, nil
4040
}

pkg/auth/filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func ToMiddleware(auth Authenticator) Middleware {
174174
}
175175
}
176176

177-
func AlwaysAdmin(req *http.Request) (user.Info, bool, error) {
177+
func AlwaysAdmin(_ *http.Request) (user.Info, bool, error) {
178178
return &user.DefaultInfo{
179179
Name: "admin",
180180
UID: "admin",

pkg/controllers/schema/schemas.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ func Register(ctx context.Context,
7171
crd.OnChange(ctx, "schema", h.OnChangeCRD)
7272
}
7373

74-
func (h *handler) OnChangeCRD(key string, crd *apiextv1.CustomResourceDefinition) (*apiextv1.CustomResourceDefinition, error) {
74+
func (h *handler) OnChangeCRD(_ string, crd *apiextv1.CustomResourceDefinition) (*apiextv1.CustomResourceDefinition, error) {
7575
h.queueRefresh()
7676
return crd, nil
7777
}
7878

79-
func (h *handler) OnChangeAPIService(key string, api *apiv1.APIService) (*apiv1.APIService, error) {
79+
func (h *handler) OnChangeAPIService(_ string, api *apiv1.APIService) (*apiv1.APIService, error) {
8080
h.queueRefresh()
8181
return api, nil
8282
}

pkg/podimpersonation/podimpersonation.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ func (s *PodImpersonation) waitForServiceAccount(ctx context.Context, client kub
305305
}
306306
defer func() {
307307
go func() {
308-
for range w.ResultChan() {
308+
for len(w.ResultChan()) > 0 {
309+
<-w.ResultChan()
309310
}
310311
}()
311312
w.Stop()
@@ -410,7 +411,8 @@ func (s *PodImpersonation) createPod(ctx context.Context, user user.Info, role *
410411
}
411412
defer func() {
412413
go func() {
413-
for range resp.ResultChan() {
414+
for len(resp.ResultChan()) > 0 {
415+
<-resp.ResultChan()
414416
}
415417
}()
416418
resp.Stop()
@@ -510,7 +512,7 @@ func (s *PodImpersonation) adminKubeConfig(user user.Info, role *rbacv1.ClusterR
510512
}, nil
511513
}
512514

513-
func (s *PodImpersonation) augmentPod(pod *v1.Pod, sa *v1.ServiceAccount, secret *v1.Secret, imageOverride string) *v1.Pod {
515+
func (s *PodImpersonation) augmentPod(pod *v1.Pod, _ *v1.ServiceAccount, secret *v1.Secret, imageOverride string) *v1.Pod {
514516
var (
515517
zero = int64(0)
516518
t = true

pkg/proxy/error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var (
99
type errorResponder struct {
1010
}
1111

12-
func (e *errorResponder) Error(w http.ResponseWriter, req *http.Request, err error) {
12+
func (e *errorResponder) Error(w http.ResponseWriter, _ *http.Request, err error) {
1313
w.WriteHeader(http.StatusInternalServerError)
1414
w.Write([]byte(err.Error()))
1515
}

pkg/resources/apigroups/apigroup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func toAPIObject(schema *types.APISchema, group v1.APIGroup) types.APIObject {
5454

5555
}
5656

57-
func (e *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (types.APIObjectList, error) {
57+
func (e *Store) List(_ *types.APIRequest, schema *types.APISchema) (types.APIObjectList, error) {
5858
groupList, err := e.discovery.ServerGroups()
5959
if err != nil {
6060
return types.APIObjectList{}, err

pkg/resources/cluster/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Apply struct {
2525
schemaFactory steveschema.Factory
2626
}
2727

28-
func (a *Apply) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
28+
func (a *Apply) ServeHTTP(_ http.ResponseWriter, req *http.Request) {
2929
var (
3030
apiContext = types.GetAPIContext(req.Context())
3131
input ApplyInput

pkg/resources/cluster/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (s *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (types.AP
173173
}, nil
174174
}
175175

176-
func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest) (chan types.APIEvent, error) {
176+
func (s *Store) Watch(apiOp *types.APIRequest, _ *types.APISchema, _ types.WatchRequest) (chan types.APIEvent, error) {
177177
result := make(chan types.APIEvent, 1)
178178
result <- types.APIEvent{
179179
Name: "local",

pkg/resources/counts/counts.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ func toAPIObject(c Count) types.APIObject {
9797
}
9898
}
9999

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

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

114114
// Watch creates a watch for the Counts schema. This returns only the counts which have changed since the watch was established
115-
func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest) (chan types.APIEvent, error) {
115+
func (s *Store) Watch(apiOp *types.APIRequest, _ *types.APISchema, _ types.WatchRequest) (chan types.APIEvent, error) {
116116
var (
117117
result = make(chan Count, 100)
118118
counts map[string]ItemCount

pkg/resources/formatters/formatter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"github.com/rancher/norman/types/convert"
66
)
77

8-
func DropHelmData(request *types.APIRequest, resource *types.RawResource) {
8+
func DropHelmData(_ *types.APIRequest, resource *types.RawResource) {
99
data := resource.APIObject.Data()
1010
if data.String("metadata", "labels", "owner") == "helm" ||
1111
data.String("metadata", "labels", "OWNER") == "TILLER" {
@@ -15,7 +15,7 @@ func DropHelmData(request *types.APIRequest, resource *types.RawResource) {
1515
}
1616
}
1717

18-
func Pod(request *types.APIRequest, resource *types.RawResource) {
18+
func Pod(_ *types.APIRequest, resource *types.RawResource) {
1919
data := resource.APIObject.Data()
2020
fields := data.StringSlice("metadata", "fields")
2121
if len(fields) > 2 {

pkg/resources/userpreferences/localpref.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func getUserName(apiOp *types.APIRequest) string {
6363
return user.GetName()
6464
}
6565

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

93-
func (l *localStore) Update(apiOp *types.APIRequest, schema *types.APISchema, data types.APIObject, id string) (types.APIObject, error) {
93+
func (l *localStore) Update(apiOp *types.APIRequest, schema *types.APISchema, data types.APIObject, _ string) (types.APIObject, error) {
9494
err := set(data.Data())
9595
if err != nil {
9696
return types.APIObject{}, err
9797
}
9898
return l.ByID(apiOp, schema, "")
9999
}
100100

101-
func (l *localStore) Delete(apiOp *types.APIRequest, schema *types.APISchema, id string) (types.APIObject, error) {
101+
func (l *localStore) Delete(apiOp *types.APIRequest, schema *types.APISchema, _ string) (types.APIObject, error) {
102102
return l.Update(apiOp, schema, types.APIObject{
103103
Object: map[string]interface{}{},
104104
}, "")

pkg/schema/table/mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (t *ColumnMapper) FromInternal(d data.Object) {
4242
}
4343
}
4444

45-
func (t *ColumnMapper) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
45+
func (t *ColumnMapper) ModifySchema(schema *types.Schema, _ *types.Schemas) error {
4646
as := &types2.APISchema{
4747
Schema: schema,
4848
}

pkg/server/handler/handlers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/rancher/steve/pkg/schema"
88
)
99

10-
func k8sAPI(sf schema.Factory, apiOp *types.APIRequest) {
10+
func k8sAPI(_ schema.Factory, apiOp *types.APIRequest) {
1111
vars := mux.Vars(apiOp.Request)
1212
apiOp.Name = vars["name"]
1313
apiOp.Type = vars["type"]
@@ -27,6 +27,6 @@ func k8sAPI(sf schema.Factory, apiOp *types.APIRequest) {
2727
}
2828
}
2929

30-
func apiRoot(sf schema.Factory, apiOp *types.APIRequest) {
30+
func apiRoot(_ schema.Factory, apiOp *types.APIRequest) {
3131
apiOp.Type = "apiRoot"
3232
}

pkg/stores/partition/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ func moveToUnderscore(obj *unstructured.Unstructured) *unstructured.Unstructured
368368
return obj
369369
}
370370

371-
func toAPIEvent(apiOp *types.APIRequest, schema *types.APISchema, event watch.Event) types.APIEvent {
371+
func toAPIEvent(_ *types.APIRequest, schema *types.APISchema, event watch.Event) types.APIEvent {
372372
name := types.ChangeAPIEvent
373373
switch event.Type {
374374
case watch.Deleted:

pkg/stores/proxy/proxy_store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func (s *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (*unstruc
242242
return result, buffer, err
243243
}
244244

245-
func (s *Store) list(apiOp *types.APIRequest, schema *types.APISchema, client dynamic.ResourceInterface) (*unstructured.UnstructuredList, error) {
245+
func (s *Store) list(apiOp *types.APIRequest, _ *types.APISchema, client dynamic.ResourceInterface) (*unstructured.UnstructuredList, error) {
246246
opts := metav1.ListOptions{}
247247
if err := decodeParams(apiOp, &opts); err != nil {
248248
return nil, nil

pkg/stores/proxy/rbac_store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type rbacPartitioner struct {
4040

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

9090
// Store returns an UnstructuredStore suited to listing and watching resources by partition.
91-
func (p *rbacPartitioner) Store(apiOp *types.APIRequest, partition partition.Partition) (partition.UnstructuredStore, error) {
91+
func (p *rbacPartitioner) Store(_ *types.APIRequest, partition partition.Partition) (partition.UnstructuredStore, error) {
9292
return &byNameOrNamespaceStore{
9393
Store: p.proxyStore,
9494
partition: partition.(Partition),

pkg/summarycache/summarycache.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ func (s *SummaryCache) process(obj runtime.Object) (*summary.SummarizedObject, [
277277
if schema == nil {
278278
continue
279279
}
280-
copy := rel
281-
if copy.Namespace == "" && attributes.Namespaced(schema) {
282-
copy.Namespace = summary.Namespace
280+
relCopy := rel
281+
if relCopy.Namespace == "" && attributes.Namespaced(schema) {
282+
relCopy.Namespace = summary.Namespace
283283
}
284-
rels = append(rels, &copy)
284+
rels = append(rels, &relCopy)
285285
}
286286

287287
return summary, rels
@@ -324,17 +324,17 @@ func (s *SummaryCache) refersTo(summarized *summary.SummarizedObject, rel *summa
324324
return summarized.Namespace == ns
325325
}
326326

327-
func (s *SummaryCache) OnAdd(_ runtimeschema.GroupVersionKind, key string, obj runtime.Object) error {
327+
func (s *SummaryCache) OnAdd(_ runtimeschema.GroupVersionKind, _ string, obj runtime.Object) error {
328328
s.Add(obj)
329329
return nil
330330
}
331331

332-
func (s *SummaryCache) OnRemove(_ runtimeschema.GroupVersionKind, key string, obj runtime.Object) error {
332+
func (s *SummaryCache) OnRemove(_ runtimeschema.GroupVersionKind, _ string, obj runtime.Object) error {
333333
s.Remove(obj)
334334
return nil
335335
}
336336

337-
func (s *SummaryCache) OnChange(_ runtimeschema.GroupVersionKind, key string, obj, oldObj runtime.Object) error {
337+
func (s *SummaryCache) OnChange(_ runtimeschema.GroupVersionKind, _ string, obj, oldObj runtime.Object) error {
338338
s.Change(obj, oldObj)
339339
return nil
340340
}

0 commit comments

Comments
 (0)