mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-05 07:37:12 +00:00
Enable 'makezero' and 'prealloc' linters, and require 'any' instead of 'interface{}'
Enforce importas: - go.pinniped.dev/generated/latest/apis/supervisor/config/v1alpha1 - go.pinniped.dev/generated/latest/apis/supervisor/idp/v1alpha1
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
// Copyright 2020 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package controllerlib
|
||||
|
||||
type die string
|
||||
|
||||
func crash(i interface{}) {
|
||||
func crash(i any) {
|
||||
mustDie, ok := i.(die)
|
||||
if ok {
|
||||
panic(string(mustDie))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package controllerlib
|
||||
@@ -60,7 +60,7 @@ func WithInformer(getter InformerGetter, filter Filter, opt InformerOption) Opti
|
||||
}
|
||||
|
||||
_, err := informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
AddFunc: func(obj any) {
|
||||
object := metaOrDie(obj)
|
||||
if filter.Add(object) {
|
||||
plog.Debug("handling add",
|
||||
@@ -73,7 +73,7 @@ func WithInformer(getter InformerGetter, filter Filter, opt InformerOption) Opti
|
||||
c.add(filter, object)
|
||||
}
|
||||
},
|
||||
UpdateFunc: func(oldObj, newObj interface{}) {
|
||||
UpdateFunc: func(oldObj, newObj any) {
|
||||
oldObject := metaOrDie(oldObj)
|
||||
newObject := metaOrDie(newObj)
|
||||
if filter.Update(oldObject, newObject) {
|
||||
@@ -87,7 +87,7 @@ func WithInformer(getter InformerGetter, filter Filter, opt InformerOption) Opti
|
||||
c.add(filter, newObject)
|
||||
}
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
DeleteFunc: func(obj any) {
|
||||
accessor, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||
@@ -146,7 +146,7 @@ func toOnceOpt(opt Option) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func metaOrDie(obj interface{}) metav1.Object {
|
||||
func metaOrDie(obj any) metav1.Object {
|
||||
accessor, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
panic(err) // this should never happen
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2020 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package controllerlib
|
||||
@@ -16,7 +16,7 @@ var _ events.EventRecorder = klogRecorder{}
|
||||
|
||||
type klogRecorder struct{}
|
||||
|
||||
func (n klogRecorder) Eventf(regarding runtime.Object, related runtime.Object, eventtype, reason, action, note string, args ...interface{}) {
|
||||
func (n klogRecorder) Eventf(regarding runtime.Object, related runtime.Object, eventtype, reason, action, note string, args ...any) {
|
||||
plog.Debug("recording event",
|
||||
"regarding", regarding,
|
||||
"related", related,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2020 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package controllerlib
|
||||
@@ -34,7 +34,7 @@ type Key struct {
|
||||
Name string
|
||||
|
||||
// TODO determine if it makes sense to add a field like:
|
||||
// Extra interface{}
|
||||
// Extra any
|
||||
// This would allow a custom ParentFunc to pass extra data through to the Syncer
|
||||
// The boxed type would have to be comparable (i.e. usable as a map key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user