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

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

		secret, err := newCASecret(cr, name)
		if err != nil {
			return nil, err
		}

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

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

		return secret, nil
	} else if err != nil {
		return nil, err
	}

	log.Info("ca secret exists", "secret", found.Name)
	return found, nil
}
// reconcileCASecret ensures the CA TLS Secret is created.
// The secret is returned upon success to be used by other reconcilers.
reconcileCASecret ensures the CA TLS Secret is created.
The secret is returned upon success to be used by other reconcilers.
// reconcileCASecret ensures the CA TLS Secret is created . // The secret is returned upon success to be used by other reconcilers .
func (r *ReconcileRethinkDBCluster) reconcileCASecret(cr *rethinkdbv1alpha1.RethinkDBCluster) (*corev1.Secret, error) {
	name := fmt.Sprintf("%s-ca", cr.Name)
	found := &corev1.Secret{}
	err := r.client.Get(context.TODO(), types.NamespacedName{Name: name, Namespace: cr.Namespace}, found)
	if err != nil && errors.IsNotFound(err) {
		log.Info("creating new ca secret", "secret", name)
		secret, err := newCASecret(cr, name)
		if err != nil {
			return nil, err
		}
		if err = controllerutil.SetControllerReference(cr, secret, r.scheme); err != nil {
			return nil, err
		}
		err = r.client.Create(context.TODO(), secret)
		if err != nil {
			return nil, err
		}
		return secret, nil
	} else if err != nil {
		return nil, err
	}
	log.Info("ca secret exists", "secret", found.Name)
	return found, nil
}
func ( r * ReconcileRethinkDBCluster ) reconcileCASecret ( cr * rethinkdbv1alpha1 . RethinkDBCluster ) ( * corev1 . Secret , error ) { name := fmt . Sprintf ( " " , cr . Name ) found := & corev1 . Secret { } err := r . client . Get ( context . TODO ( ) , types . NamespacedName { Name : name , Namespace : cr . Namespace } , found ) if err != nil && errors . IsNotFound ( err ) { log . Info ( " " , " " , name ) secret , err := newCASecret ( cr , name ) if err != nil { return nil , err } if err = controllerutil . SetControllerReference ( cr , secret , r . scheme ) ; err != nil { return nil , err } err = r . client . Create ( context . TODO ( ) , secret ) if err != nil { return nil , err } return secret , nil } else if err != nil { return nil , err } log . Info ( " " , " " , found . Name ) return found , nil }
reconcileCASecret ensures the CA TLS Secret is created.
reconcileCASecret ensures the CA TLS Secret is created .
// Set RethinkDB instance as the owner and controller