func (r *ReconcileRethinkDBCluster) reconcileTLSSecretWithSuffix(cr *rethinkdbv1alpha1.RethinkDBCluster, caSecret *corev1.Secret, suffix string) error {
	found := &corev1.Secret{}
	name := fmt.Sprintf("%s-%s", cr.Name, suffix)

	err := r.client.Get(context.TODO(), types.NamespacedName{Name: name, Namespace: cr.Namespace}, found)
	if err != nil && errors.IsNotFound(err) {
		log.Info("creating new secret", "secret", name)

		caCert, err := parsePEMEncodedCert(caSecret.Data[corev1.TLSCertKey])
		if err != nil {
			return err
		}

		caKey, err := parsePEMEncodedPrivateKey(caSecret.Data[corev1.TLSPrivateKeyKey])
		if err != nil {
			return err
		}

		secret, err := newCertificateSecret(cr, name, caCert, caKey)
		if err != nil {
			return err
		}

		// Set RethinkDB instance as the owner and controller
		if err = controllerutil.SetControllerReference(cr, secret, r.scheme); err != nil {
			return err
		}

		return r.client.Create(context.TODO(), secret)
	} else if err != nil {
		return err
	}

	log.Info("secret exists", "secret", found.Name)
	return nil
}
// reconcileTLSSecretWithSuffix ensures the TLS Secret is created for the given Service with the given suffix.
reconcileTLSSecretWithSuffix ensures the TLS Secret is created for the given Service with the given suffix.
// reconcileTLSSecretWithSuffix ensures the TLS Secret is created for the given Service with the given suffix .
func (r *ReconcileRethinkDBCluster) reconcileTLSSecretWithSuffix(cr *rethinkdbv1alpha1.RethinkDBCluster, caSecret *corev1.Secret, suffix string) error {
	found := &corev1.Secret{}
	name := fmt.Sprintf("%s-%s", cr.Name, suffix)
	err := r.client.Get(context.TODO(), types.NamespacedName{Name: name, Namespace: cr.Namespace}, found)
	if err != nil && errors.IsNotFound(err) {
		log.Info("creating new secret", "secret", name)
		caCert, err := parsePEMEncodedCert(caSecret.Data[corev1.TLSCertKey])
		if err != nil {
			return err
		}
		caKey, err := parsePEMEncodedPrivateKey(caSecret.Data[corev1.TLSPrivateKeyKey])
		if err != nil {
			return err
		}
		secret, err := newCertificateSecret(cr, name, caCert, caKey)
		if err != nil {
			return err
		}
		if err = controllerutil.SetControllerReference(cr, secret, r.scheme); err != nil {
			return err
		}
		return r.client.Create(context.TODO(), secret)
	} else if err != nil {
		return err
	}
	log.Info("secret exists", "secret", found.Name)
	return nil
}
func ( r * ReconcileRethinkDBCluster ) reconcileTLSSecretWithSuffix ( cr * rethinkdbv1alpha1 . RethinkDBCluster , caSecret * corev1 . Secret , suffix string ) error { found := & corev1 . Secret { } name := fmt . Sprintf ( " " , cr . Name , suffix ) err := r . client . Get ( context . TODO ( ) , types . NamespacedName { Name : name , Namespace : cr . Namespace } , found ) if err != nil && errors . IsNotFound ( err ) { log . Info ( " " , " " , name ) caCert , err := parsePEMEncodedCert ( caSecret . Data [ corev1 . TLSCertKey ] ) if err != nil { return err } caKey , err := parsePEMEncodedPrivateKey ( caSecret . Data [ corev1 . TLSPrivateKeyKey ] ) if err != nil { return err } secret , err := newCertificateSecret ( cr , name , caCert , caKey ) if err != nil { return err } if err = controllerutil . SetControllerReference ( cr , secret , r . scheme ) ; err != nil { return err } return r . client . Create ( context . TODO ( ) , secret ) } else if err != nil { return err } log . Info ( " " , " " , found . Name ) return nil }
reconcileTLSSecretWithSuffix ensures the TLS Secret is created for the given Service with the given suffix.
reconcileTLSSecretWithSuffix ensures the TLS Secret is created for the given Service with the given suffix .
// Set RethinkDB instance as the owner and controller