mirror of
https://github.com/external-secrets/external-secrets.git
synced 2024-12-14 11:57:59 +00:00
Merge pull request #196 from ElsaChelala/docs
Added doc strings and comments for the controllers package
This commit is contained in:
commit
526a96d825
4 changed files with 12 additions and 0 deletions
|
@ -52,6 +52,9 @@ type Reconciler struct {
|
|||
ControllerClass string
|
||||
}
|
||||
|
||||
// Reconcile implements the main reconciliation loop
|
||||
// for watched objects (ExternalSecret, ClusterSecretStore and SecretStore),
|
||||
// and updates/creates a Kubernetes secret based on them.
|
||||
func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
log := r.Log.WithValues("ExternalSecret", req.NamespacedName)
|
||||
|
||||
|
@ -164,6 +167,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 +195,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 +228,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 +253,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{}).
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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{}).
|
||||
|
|
Loading…
Reference in a new issue