func (c *Client) ClientCreateSecret(ctx context.Context, values map[string][]byte,
	instance v1alpha1.APIObject, scheme *runtime.Scheme) (reconcile.Result, error) {
	desiredSecret, err := NewSecret(instance, values, instance.GetType())
	if err != nil {
		return reconcile.Result{}, err
	}
	err = c.Create(ctx, desiredSecret)
	if err != nil {
		return reconcile.Result{}, err
	}
	err = c.getSecretRefAndSetStatus(ctx, desiredSecret, instance, scheme)
	if err != nil {
		return reconcile.Result{}, err
	}
	return reconcile.Result{}, nil
}
ClientCreateSecret creates a new Secret resource, uses the client to save it to the cluster and gets its resource
ref to set the status of instance
package crd
import (
	"context"
	"github.com/go-logr/logr"
	corev1 "k8s.io/api/core/v1"
	apierrors "k8s.io/apimachinery/pkg/api/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/client-go/kubernetes/scheme"
	"k8s.io/client-go/tools/reference"
	"sigs.k8s.io/controller-runtime/pkg/client"
	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
	"sigs.k8s.io/controller-runtime/pkg/event"
	"sigs.k8s.io/controller-runtime/pkg/predicate"
	"sigs.k8s.io/controller-runtime/pkg/reconcile"
	"github.com/mittwald/kubernetes-secret-generator/pkg/apis/secretgenerator/v1alpha1"
)
func NewSecret(ownerCR metav1.Object, values map[string][]byte, secretType string) (*corev1.Secret, error) {
	secret := &corev1.Secret{
		ObjectMeta: metav1.ObjectMeta{
			Name:      ownerCR.GetName(),
			Namespace: ownerCR.GetNamespace(),
			Labels:    ownerCR.GetLabels(),
		},
		Data: values,
	}
	if secretType != "" {
		secret.Type = corev1.SecretType(secretType)
	}
	err := controllerutil.SetControllerReference(ownerCR, secret, scheme.Scheme)
	if err != nil {
		return nil, err
	}
	return secret, nil
}
func CheckError(err error) (reconcile.Result, error) {
	if apierrors.IsNotFound(err) {
		return reconcile.Result{}, nil
	}
	return reconcile.Result{Requeue: true}, err
}
func IgnoreStatusUpdatePredicate() predicate.Predicate {
	return predicate.Funcs{
		UpdateFunc: func(e event.UpdateEvent) bool {
			return e.MetaOld.GetGeneration() != e.MetaNew.GetGeneration()
		},
		DeleteFunc: func(e event.DeleteEvent) bool {
			return !e.DeleteStateUnknown
		},
	}
}
type Client struct {
	client.Client
}