1
0
Fork 0

Update to go1.22

Co-authored-by: Julien Salleyron <julien.salleyron@gmail.com>
This commit is contained in:
Ludovic Fernandez 2024-02-07 17:14:07 +01:00 committed by GitHub
parent e11ff98608
commit d5cb9b50f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 4189 additions and 3419 deletions

View file

@ -51,6 +51,7 @@ type sharedInformerFactory struct {
lock sync.Mutex
defaultResync time.Duration
customResync map[reflect.Type]time.Duration
transform cache.TransformFunc
informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
@ -89,6 +90,14 @@ func WithNamespace(namespace string) SharedInformerOption {
}
}
// WithTransform sets a transform on all informers.
func WithTransform(transform cache.TransformFunc) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.transform = transform
return factory
}
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync)
@ -193,6 +202,7 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal
}
informer = newFunc(f.client, resyncPeriod)
informer.SetTransform(f.transform)
f.informers[informerType] = informer
return informer

View file

@ -641,7 +641,7 @@ func createForwardAuthMiddleware(k8sClient Client, namespace string, auth *traef
return nil, nil
}
if len(auth.Address) == 0 {
return nil, fmt.Errorf("forward authentication requires an address")
return nil, errors.New("forward authentication requires an address")
}
forwardAuth := &dynamic.ForwardAuth{
@ -734,7 +734,7 @@ func createBasicAuthMiddleware(client Client, namespace string, basicAuth *traef
}
if basicAuth.Secret == "" {
return nil, fmt.Errorf("auth secret must be set")
return nil, errors.New("auth secret must be set")
}
secret, ok, err := client.GetSecret(namespace, basicAuth.Secret)
@ -781,7 +781,7 @@ func createDigestAuthMiddleware(client Client, namespace string, digestAuth *tra
}
if digestAuth.Secret == "" {
return nil, fmt.Errorf("auth secret must be set")
return nil, errors.New("auth secret must be set")
}
secret, ok, err := client.GetSecret(namespace, digestAuth.Secret)

View file

@ -2,7 +2,7 @@ package ingress
import (
"context"
"fmt"
"errors"
"testing"
"time"
@ -40,9 +40,9 @@ func TestTranslateNotFoundError(t *testing.T) {
},
{
desc: "not a kubernetes not found error",
err: fmt.Errorf("bar error"),
err: errors.New("bar error"),
expectedExists: false,
expectedError: fmt.Errorf("bar error"),
expectedError: errors.New("bar error"),
},
}