You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-08-08 22:46:33 +02:00
Update go-redis/redis to v8 (#801)
* update go-redis/redis to v8 testify, ginko and gomega have also been updated. * update changelog * Update pkg/sessions/redis/redis_store_test.go Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk> Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>
This commit is contained in:
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/go-redis/redis/v7"
|
||||
"github.com/go-redis/redis/v8"
|
||||
)
|
||||
|
||||
// Client is wrapper interface for redis.Client and redis.ClusterClient.
|
||||
@ -25,15 +25,15 @@ func newClient(c *redis.Client) Client {
|
||||
}
|
||||
|
||||
func (c *client) Get(ctx context.Context, key string) ([]byte, error) {
|
||||
return c.WithContext(ctx).Get(key).Bytes()
|
||||
return c.Client.Get(ctx, key).Bytes()
|
||||
}
|
||||
|
||||
func (c *client) Set(ctx context.Context, key string, value []byte, expiration time.Duration) error {
|
||||
return c.WithContext(ctx).Set(key, value, expiration).Err()
|
||||
return c.Client.Set(ctx, key, value, expiration).Err()
|
||||
}
|
||||
|
||||
func (c *client) Del(ctx context.Context, key string) error {
|
||||
return c.WithContext(ctx).Del(key).Err()
|
||||
return c.Client.Del(ctx, key).Err()
|
||||
}
|
||||
|
||||
var _ Client = (*clusterClient)(nil)
|
||||
@ -47,13 +47,13 @@ func newClusterClient(c *redis.ClusterClient) Client {
|
||||
}
|
||||
|
||||
func (c *clusterClient) Get(ctx context.Context, key string) ([]byte, error) {
|
||||
return c.WithContext(ctx).Get(key).Bytes()
|
||||
return c.ClusterClient.Get(ctx, key).Bytes()
|
||||
}
|
||||
|
||||
func (c *clusterClient) Set(ctx context.Context, key string, value []byte, expiration time.Duration) error {
|
||||
return c.WithContext(ctx).Set(key, value, expiration).Err()
|
||||
return c.ClusterClient.Set(ctx, key, value, expiration).Err()
|
||||
}
|
||||
|
||||
func (c *clusterClient) Del(ctx context.Context, key string) error {
|
||||
return c.WithContext(ctx).Del(key).Err()
|
||||
return c.ClusterClient.Del(ctx, key).Err()
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"io/ioutil"
|
||||
"time"
|
||||
|
||||
"github.com/go-redis/redis/v7"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
|
||||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/sessions"
|
||||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/logger"
|
||||
|
@ -1,6 +1,7 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
@ -8,7 +9,7 @@ import (
|
||||
|
||||
"github.com/Bose/minisentinel"
|
||||
"github.com/alicebob/miniredis/v2"
|
||||
"github.com/go-redis/redis/v7"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
|
||||
sessionsapi "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/sessions"
|
||||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/logger"
|
||||
@ -20,10 +21,20 @@ import (
|
||||
|
||||
const redisPassword = "0123456789abcdefghijklmnopqrstuv"
|
||||
|
||||
// wrappedRedisLogger wraps a logger so that we can coerce the logger to
|
||||
// fit the expected signature for go-redis logging
|
||||
type wrappedRedisLogger struct {
|
||||
*log.Logger
|
||||
}
|
||||
|
||||
func (l *wrappedRedisLogger) Printf(_ context.Context, format string, v ...interface{}) {
|
||||
l.Logger.Printf(format, v...)
|
||||
}
|
||||
|
||||
func TestSessionStore(t *testing.T) {
|
||||
logger.SetOutput(GinkgoWriter)
|
||||
|
||||
redisLogger := log.New(os.Stderr, "redis: ", log.LstdFlags|log.Lshortfile)
|
||||
redisLogger := &wrappedRedisLogger{Logger: log.New(os.Stderr, "redis: ", log.LstdFlags|log.Lshortfile)}
|
||||
redisLogger.SetOutput(GinkgoWriter)
|
||||
redis.SetLogger(redisLogger)
|
||||
|
||||
|
Reference in New Issue
Block a user