| 525 | } |
| 526 | |
| 527 | func redisStorageStorer(c client.Client, s *v1alpha1.Storage, nsPrefix string) (storage.Storer, *redis.Options, error) { |
| 528 | // get the password from the redis secret |
| 529 | secret := &corev1.Secret{} |
| 530 | if err := c.Get(context.TODO(), client.ObjectKey{Name: s.Name, Namespace: s.Namespace}, secret); err != nil { |
| 531 | return nil, nil, err |
| 532 | } |
| 533 | |
| 534 | passwordBytes, ok := secret.Data["password"] |
| 535 | if !ok { |
| 536 | return nil, nil, errors.New("password not found in secret") |
| 537 | } |
| 538 | password := string(passwordBytes) |
| 539 | |
| 540 | url := fmt.Sprintf("%s.%s.svc.cluster.local:6379", s.Name, s.Namespace) |
| 541 | // New redis storage |
| 542 | opts := &redis.Options{ |
| 543 | Addr: url, |
| 544 | Password: password, |
| 545 | DB: 0, |
| 546 | } |
| 547 | return rediscache.NewStorage(opts, nsPrefix), opts, nil |
| 548 | } |
| 549 | |
| 550 | func namespace() (string, error) { |
| 551 | ns, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace") |