From 7eb05afe2af9c26094547def2d8efee32d723142 Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Wed, 18 Dec 2024 02:54:21 +0100 Subject: [PATCH] misc: better condition naming --- .../infisicalpushsecret/conditions.go | 16 ++++++++-------- .../infisicalpushsecret_controller.go | 2 +- .../infisicalpushsecret_helper.go | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/k8-operator/controllers/infisicalpushsecret/conditions.go b/k8-operator/controllers/infisicalpushsecret/conditions.go index 65f32d4a3..dd17bc913 100644 --- a/k8-operator/controllers/infisicalpushsecret/conditions.go +++ b/k8-operator/controllers/infisicalpushsecret/conditions.go @@ -9,7 +9,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func (r *InfisicalPushSecretReconciler) SetSuccessfullyReconciledConditions(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, err error) error { +func (r *InfisicalPushSecretReconciler) SetReconcileStatusCondition(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, err error) error { if infisicalPushSecret.Status.Conditions == nil { infisicalPushSecret.Status.Conditions = []metav1.Condition{} @@ -17,14 +17,14 @@ func (r *InfisicalPushSecretReconciler) SetSuccessfullyReconciledConditions(ctx if err != nil { meta.SetStatusCondition(&infisicalPushSecret.Status.Conditions, metav1.Condition{ - Type: "secrets.infisical.com/SuccessfullyReconciled", + Type: "secrets.infisical.com/Reconcile", Status: metav1.ConditionTrue, Reason: "Error", Message: fmt.Sprintf("Reconcile failed, secrets were not pushed to Infisical. Error: %s", err.Error()), }) } else { meta.SetStatusCondition(&infisicalPushSecret.Status.Conditions, metav1.Condition{ - Type: "secrets.infisical.com/SuccessfullyReconciled", + Type: "secrets.infisical.com/Reconcile", Status: metav1.ConditionFalse, Reason: "OK", Message: "Reconcile succeeded, secrets were pushed to Infisical", @@ -35,7 +35,7 @@ func (r *InfisicalPushSecretReconciler) SetSuccessfullyReconciledConditions(ctx } -func (r *InfisicalPushSecretReconciler) SetFailedToReplaceSecretsConditions(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, failMessage string) error { +func (r *InfisicalPushSecretReconciler) SetFailedToReplaceSecretsStatusCondition(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, failMessage string) error { if infisicalPushSecret.Status.Conditions == nil { infisicalPushSecret.Status.Conditions = []metav1.Condition{} } @@ -59,7 +59,7 @@ func (r *InfisicalPushSecretReconciler) SetFailedToReplaceSecretsConditions(ctx return r.Client.Status().Update(ctx, infisicalPushSecret) } -func (r *InfisicalPushSecretReconciler) SetFailedToCreateSecretsConditions(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, failMessage string) error { +func (r *InfisicalPushSecretReconciler) SetFailedToCreateSecretsStatusCondition(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, failMessage string) error { if infisicalPushSecret.Status.Conditions == nil { infisicalPushSecret.Status.Conditions = []metav1.Condition{} } @@ -83,7 +83,7 @@ func (r *InfisicalPushSecretReconciler) SetFailedToCreateSecretsConditions(ctx c return r.Client.Status().Update(ctx, infisicalPushSecret) } -func (r *InfisicalPushSecretReconciler) SetFailedToUpdateSecretsConditions(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, failMessage string) error { +func (r *InfisicalPushSecretReconciler) SetFailedToUpdateSecretsStatusCondition(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, failMessage string) error { if infisicalPushSecret.Status.Conditions == nil { infisicalPushSecret.Status.Conditions = []metav1.Condition{} } @@ -107,7 +107,7 @@ func (r *InfisicalPushSecretReconciler) SetFailedToUpdateSecretsConditions(ctx c return r.Client.Status().Update(ctx, infisicalPushSecret) } -func (r *InfisicalPushSecretReconciler) SetFailedToDeleteSecretsConditions(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, failMessage string) error { +func (r *InfisicalPushSecretReconciler) SetFailedToDeleteSecretsStatusCondition(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, failMessage string) error { if infisicalPushSecret.Status.Conditions == nil { infisicalPushSecret.Status.Conditions = []metav1.Condition{} } @@ -131,7 +131,7 @@ func (r *InfisicalPushSecretReconciler) SetFailedToDeleteSecretsConditions(ctx c return r.Client.Status().Update(ctx, infisicalPushSecret) } -func (r *InfisicalPushSecretReconciler) SetAuthenticatedConditions(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, errorToConditionOn error) error { +func (r *InfisicalPushSecretReconciler) SetAuthenticatedStatusCondition(ctx context.Context, infisicalPushSecret *v1alpha1.InfisicalPushSecret, errorToConditionOn error) error { if infisicalPushSecret.Status.Conditions == nil { infisicalPushSecret.Status.Conditions = []metav1.Condition{} } diff --git a/k8-operator/controllers/infisicalpushsecret/infisicalpushsecret_controller.go b/k8-operator/controllers/infisicalpushsecret/infisicalpushsecret_controller.go index af5428ee7..f2125485e 100644 --- a/k8-operator/controllers/infisicalpushsecret/infisicalpushsecret_controller.go +++ b/k8-operator/controllers/infisicalpushsecret/infisicalpushsecret_controller.go @@ -159,7 +159,7 @@ func (r *InfisicalPushSecretReconciler) Reconcile(ctx context.Context, req ctrl. } err = r.ReconcileInfisicalPushSecret(ctx, logger, infisicalPushSecretCRD) - r.SetSuccessfullyReconciledConditions(ctx, &infisicalPushSecretCRD, err) + r.SetReconcileStatusCondition(ctx, &infisicalPushSecretCRD, err) if err != nil { logger.Error(err, fmt.Sprintf("unable to reconcile Infisical Push Secret. Will requeue after [requeueTime=%v]", requeueTime)) diff --git a/k8-operator/controllers/infisicalpushsecret/infisicalpushsecret_helper.go b/k8-operator/controllers/infisicalpushsecret/infisicalpushsecret_helper.go index 9ba514dbc..47fc8e69b 100644 --- a/k8-operator/controllers/infisicalpushsecret/infisicalpushsecret_helper.go +++ b/k8-operator/controllers/infisicalpushsecret/infisicalpushsecret_helper.go @@ -112,7 +112,7 @@ func (r *InfisicalPushSecretReconciler) ReconcileInfisicalPushSecret(ctx context if authDetails.AuthStrategy == "" { logger.Info("No authentication strategy found. Attempting to authenticate") authDetails, err = r.handleAuthentication(ctx, infisicalPushSecret, infisicalClient) - r.SetAuthenticatedConditions(ctx, &infisicalPushSecret, err) + r.SetAuthenticatedStatusCondition(ctx, &infisicalPushSecret, err) if err != nil { return fmt.Errorf("unable to authenticate [err=%s]", err) @@ -401,28 +401,28 @@ func (r *InfisicalPushSecretReconciler) ReconcileInfisicalPushSecret(ctx context } else { errorMessage = "" } - r.SetFailedToCreateSecretsConditions(ctx, &infisicalPushSecret, fmt.Sprintf("Failed to create secrets: [%s]", errorMessage)) + r.SetFailedToCreateSecretsStatusCondition(ctx, &infisicalPushSecret, fmt.Sprintf("Failed to create secrets: [%s]", errorMessage)) if len(secretsFailedToUpdate) > 0 { errorMessage = fmt.Sprintf("Failed to update secrets: [%s]", strings.Join(secretsFailedToUpdate, ", ")) } else { errorMessage = "" } - r.SetFailedToUpdateSecretsConditions(ctx, &infisicalPushSecret, fmt.Sprintf("Failed to update secrets: [%s]", errorMessage)) + r.SetFailedToUpdateSecretsStatusCondition(ctx, &infisicalPushSecret, fmt.Sprintf("Failed to update secrets: [%s]", errorMessage)) if len(secretsFailedToDelete) > 0 { errorMessage = fmt.Sprintf("Failed to delete secrets: [%s]", strings.Join(secretsFailedToDelete, ", ")) } else { errorMessage = "" } - r.SetFailedToDeleteSecretsConditions(ctx, &infisicalPushSecret, errorMessage) + r.SetFailedToDeleteSecretsStatusCondition(ctx, &infisicalPushSecret, errorMessage) if len(secretsFailedToReplaceById) > 0 { errorMessage = fmt.Sprintf("Failed to replace secrets: [%s]", strings.Join(secretsFailedToReplaceById, ", ")) } else { errorMessage = "" } - r.SetFailedToReplaceSecretsConditions(ctx, &infisicalPushSecret, errorMessage) + r.SetFailedToReplaceSecretsStatusCondition(ctx, &infisicalPushSecret, errorMessage) // Update the status of the InfisicalPushSecret if err := r.Client.Status().Update(ctx, &infisicalPushSecret); err != nil {