mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 16:27:40 +00:00
misc: better condition naming
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
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 {
|
if infisicalPushSecret.Status.Conditions == nil {
|
||||||
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
||||||
@@ -17,14 +17,14 @@ func (r *InfisicalPushSecretReconciler) SetSuccessfullyReconciledConditions(ctx
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
meta.SetStatusCondition(&infisicalPushSecret.Status.Conditions, metav1.Condition{
|
meta.SetStatusCondition(&infisicalPushSecret.Status.Conditions, metav1.Condition{
|
||||||
Type: "secrets.infisical.com/SuccessfullyReconciled",
|
Type: "secrets.infisical.com/Reconcile",
|
||||||
Status: metav1.ConditionTrue,
|
Status: metav1.ConditionTrue,
|
||||||
Reason: "Error",
|
Reason: "Error",
|
||||||
Message: fmt.Sprintf("Reconcile failed, secrets were not pushed to Infisical. Error: %s", err.Error()),
|
Message: fmt.Sprintf("Reconcile failed, secrets were not pushed to Infisical. Error: %s", err.Error()),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
meta.SetStatusCondition(&infisicalPushSecret.Status.Conditions, metav1.Condition{
|
meta.SetStatusCondition(&infisicalPushSecret.Status.Conditions, metav1.Condition{
|
||||||
Type: "secrets.infisical.com/SuccessfullyReconciled",
|
Type: "secrets.infisical.com/Reconcile",
|
||||||
Status: metav1.ConditionFalse,
|
Status: metav1.ConditionFalse,
|
||||||
Reason: "OK",
|
Reason: "OK",
|
||||||
Message: "Reconcile succeeded, secrets were pushed to Infisical",
|
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 {
|
if infisicalPushSecret.Status.Conditions == nil {
|
||||||
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ func (r *InfisicalPushSecretReconciler) SetFailedToReplaceSecretsConditions(ctx
|
|||||||
return r.Client.Status().Update(ctx, infisicalPushSecret)
|
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 {
|
if infisicalPushSecret.Status.Conditions == nil {
|
||||||
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ func (r *InfisicalPushSecretReconciler) SetFailedToCreateSecretsConditions(ctx c
|
|||||||
return r.Client.Status().Update(ctx, infisicalPushSecret)
|
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 {
|
if infisicalPushSecret.Status.Conditions == nil {
|
||||||
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ func (r *InfisicalPushSecretReconciler) SetFailedToUpdateSecretsConditions(ctx c
|
|||||||
return r.Client.Status().Update(ctx, infisicalPushSecret)
|
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 {
|
if infisicalPushSecret.Status.Conditions == nil {
|
||||||
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ func (r *InfisicalPushSecretReconciler) SetFailedToDeleteSecretsConditions(ctx c
|
|||||||
return r.Client.Status().Update(ctx, infisicalPushSecret)
|
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 {
|
if infisicalPushSecret.Status.Conditions == nil {
|
||||||
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
infisicalPushSecret.Status.Conditions = []metav1.Condition{}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ func (r *InfisicalPushSecretReconciler) Reconcile(ctx context.Context, req ctrl.
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = r.ReconcileInfisicalPushSecret(ctx, logger, infisicalPushSecretCRD)
|
err = r.ReconcileInfisicalPushSecret(ctx, logger, infisicalPushSecretCRD)
|
||||||
r.SetSuccessfullyReconciledConditions(ctx, &infisicalPushSecretCRD, err)
|
r.SetReconcileStatusCondition(ctx, &infisicalPushSecretCRD, err)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err, fmt.Sprintf("unable to reconcile Infisical Push Secret. Will requeue after [requeueTime=%v]", requeueTime))
|
logger.Error(err, fmt.Sprintf("unable to reconcile Infisical Push Secret. Will requeue after [requeueTime=%v]", requeueTime))
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ func (r *InfisicalPushSecretReconciler) ReconcileInfisicalPushSecret(ctx context
|
|||||||
if authDetails.AuthStrategy == "" {
|
if authDetails.AuthStrategy == "" {
|
||||||
logger.Info("No authentication strategy found. Attempting to authenticate")
|
logger.Info("No authentication strategy found. Attempting to authenticate")
|
||||||
authDetails, err = r.handleAuthentication(ctx, infisicalPushSecret, infisicalClient)
|
authDetails, err = r.handleAuthentication(ctx, infisicalPushSecret, infisicalClient)
|
||||||
r.SetAuthenticatedConditions(ctx, &infisicalPushSecret, err)
|
r.SetAuthenticatedStatusCondition(ctx, &infisicalPushSecret, err)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to authenticate [err=%s]", err)
|
return fmt.Errorf("unable to authenticate [err=%s]", err)
|
||||||
@@ -401,28 +401,28 @@ func (r *InfisicalPushSecretReconciler) ReconcileInfisicalPushSecret(ctx context
|
|||||||
} else {
|
} else {
|
||||||
errorMessage = ""
|
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 {
|
if len(secretsFailedToUpdate) > 0 {
|
||||||
errorMessage = fmt.Sprintf("Failed to update secrets: [%s]", strings.Join(secretsFailedToUpdate, ", "))
|
errorMessage = fmt.Sprintf("Failed to update secrets: [%s]", strings.Join(secretsFailedToUpdate, ", "))
|
||||||
} else {
|
} else {
|
||||||
errorMessage = ""
|
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 {
|
if len(secretsFailedToDelete) > 0 {
|
||||||
errorMessage = fmt.Sprintf("Failed to delete secrets: [%s]", strings.Join(secretsFailedToDelete, ", "))
|
errorMessage = fmt.Sprintf("Failed to delete secrets: [%s]", strings.Join(secretsFailedToDelete, ", "))
|
||||||
} else {
|
} else {
|
||||||
errorMessage = ""
|
errorMessage = ""
|
||||||
}
|
}
|
||||||
r.SetFailedToDeleteSecretsConditions(ctx, &infisicalPushSecret, errorMessage)
|
r.SetFailedToDeleteSecretsStatusCondition(ctx, &infisicalPushSecret, errorMessage)
|
||||||
|
|
||||||
if len(secretsFailedToReplaceById) > 0 {
|
if len(secretsFailedToReplaceById) > 0 {
|
||||||
errorMessage = fmt.Sprintf("Failed to replace secrets: [%s]", strings.Join(secretsFailedToReplaceById, ", "))
|
errorMessage = fmt.Sprintf("Failed to replace secrets: [%s]", strings.Join(secretsFailedToReplaceById, ", "))
|
||||||
} else {
|
} else {
|
||||||
errorMessage = ""
|
errorMessage = ""
|
||||||
}
|
}
|
||||||
r.SetFailedToReplaceSecretsConditions(ctx, &infisicalPushSecret, errorMessage)
|
r.SetFailedToReplaceSecretsStatusCondition(ctx, &infisicalPushSecret, errorMessage)
|
||||||
|
|
||||||
// Update the status of the InfisicalPushSecret
|
// Update the status of the InfisicalPushSecret
|
||||||
if err := r.Client.Status().Update(ctx, &infisicalPushSecret); err != nil {
|
if err := r.Client.Status().Update(ctx, &infisicalPushSecret); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user