MCPcopy Create free account
hub / github.com/encoder-run/operator / redisStorageStorer

Function redisStorageStorer

cmd/repositoryembedder/main.go:527–548  ·  view source on GitHub ↗
(c client.Client, s *v1alpha1.Storage, nsPrefix string)

Source from the content-addressed store, hash-verified

525}
526
527func 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
550func namespace() (string, error) {
551 ns, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected