Browse Source

dded doc strings and comments for the controllers package

Elsa Chelala 4 years ago
parent
commit
776ef0d27b

+ 6 - 0
pkg/controllers/externalsecret/externalsecret_controller.go

@@ -52,6 +52,7 @@ type Reconciler struct {
 	ControllerClass string
 }
 
+// Reconcile returns a new ExternalSecret object.
 func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
 	log := r.Log.WithValues("ExternalSecret", req.NamespacedName)
 
@@ -164,6 +165,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 	}, nil
 }
 
+// shouldProcessStore returns true if the store should be processed.
 func shouldProcessStore(store esv1alpha1.GenericStore, class string) bool {
 	if store.GetSpec().Controller == "" || store.GetSpec().Controller == class {
 		return true
@@ -191,12 +193,14 @@ func mergeTemplate(secret *corev1.Secret, externalSecret esv1alpha1.ExternalSecr
 	mergeMap(secret.ObjectMeta.Annotations, externalSecret.Spec.Target.Template.Metadata.Annotations)
 }
 
+// mergeMap performs a deep clone from src to dest.
 func mergeMap(dest, src map[string]string) {
 	for k, v := range src {
 		dest[k] = v
 	}
 }
 
+// getStore returns the store with the provided ExternalSecret.
 func (r *Reconciler) getStore(ctx context.Context, externalSecret *esv1alpha1.ExternalSecret) (esv1alpha1.GenericStore, error) {
 	ref := types.NamespacedName{
 		Name: externalSecret.Spec.SecretStoreRef.Name,
@@ -222,6 +226,7 @@ func (r *Reconciler) getStore(ctx context.Context, externalSecret *esv1alpha1.Ex
 	return &store, nil
 }
 
+// getProviderSecretData returns the provider's secret data with the provided ExternalSecret.
 func (r *Reconciler) getProviderSecretData(ctx context.Context, providerClient provider.SecretsClient, externalSecret *esv1alpha1.ExternalSecret) (map[string][]byte, error) {
 	providerData := make(map[string][]byte)
 
@@ -246,6 +251,7 @@ func (r *Reconciler) getProviderSecretData(ctx context.Context, providerClient p
 	return providerData, nil
 }
 
+// SetupWithManager returns a new controller builder that will be started by the provided Manager.
 func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
 	return ctrl.NewControllerManagedBy(mgr).
 		For(&esv1alpha1.ExternalSecret{}).

+ 1 - 0
pkg/controllers/externalsecret/metrics.go

@@ -48,6 +48,7 @@ var (
 	}, []string{"name", "namespace", "condition", "status"})
 )
 
+// updateExternalSecretCondition updates the ExternalSecret conditions.
 func updateExternalSecretCondition(es *esv1alpha1.ExternalSecret, condition *esv1alpha1.ExternalSecretStatusCondition, value float64) {
 	externalSecretCondition.With(prometheus.Labels{
 		"name":      es.Name,

+ 2 - 0
pkg/controllers/externalsecret/util.go

@@ -20,6 +20,7 @@ import (
 	esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
 )
 
+// NewExternalSecretCondition a set of default options for creating an External Secret Condition.
 func NewExternalSecretCondition(condType esv1alpha1.ExternalSecretConditionType, status v1.ConditionStatus, reason, message string) *esv1alpha1.ExternalSecretStatusCondition {
 	return &esv1alpha1.ExternalSecretStatusCondition{
 		Type:               condType,
@@ -66,6 +67,7 @@ func SetExternalSecretCondition(es *esv1alpha1.ExternalSecret, condition esv1alp
 	updateExternalSecretCondition(es, &condition, 1.0)
 }
 
+// filterOutCondition returns an empty set of conditions with the provided type.
 func filterOutCondition(conditions []esv1alpha1.ExternalSecretStatusCondition, condType esv1alpha1.ExternalSecretConditionType) []esv1alpha1.ExternalSecretStatusCondition {
 	newConditions := make([]esv1alpha1.ExternalSecretStatusCondition, 0, len(conditions))
 	for _, c := range conditions {

+ 1 - 0
pkg/controllers/secretstore/secretstore_controller.go

@@ -42,6 +42,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 	return ctrl.Result{}, nil
 }
 
+// SetupWithManager returns a new controller builder that will be started by the provided Manager.
 func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
 	return ctrl.NewControllerManagedBy(mgr).
 		For(&esv1alpha1.SecretStore{}).