All checks were successful
Build and Publish / build-release (push) Successful in 8m29s
71 lines
1.9 KiB
Go
71 lines
1.9 KiB
Go
package conditions
|
|
|
|
import (
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
zitadelv1alpha1 "gitea.corredorconect.com/software-engineering/zitadel-resources-operator/api/v1alpha1"
|
|
)
|
|
|
|
func SetReadyHealthty(c Conditioner) {
|
|
c.SetCondition(metav1.Condition{
|
|
Type: zitadelv1alpha1.ConditionTypeReady,
|
|
Status: metav1.ConditionTrue,
|
|
Reason: zitadelv1alpha1.ConditionReasonHealthy,
|
|
Message: "Healthy",
|
|
})
|
|
}
|
|
|
|
func SetReadyUnhealthtyWithError(c Conditioner, err error) {
|
|
c.SetCondition(metav1.Condition{
|
|
Type: zitadelv1alpha1.ConditionTypeReady,
|
|
Status: metav1.ConditionFalse,
|
|
Reason: zitadelv1alpha1.ConditionReasonHealthy,
|
|
Message: err.Error(),
|
|
})
|
|
}
|
|
|
|
func SetReadyCreatedWithMessage(c Conditioner, message string) {
|
|
c.SetCondition(metav1.Condition{
|
|
Type: zitadelv1alpha1.ConditionTypeReady,
|
|
Status: metav1.ConditionTrue,
|
|
Reason: zitadelv1alpha1.ConditionReasonCreated,
|
|
Message: message,
|
|
})
|
|
}
|
|
|
|
func SetReadyCreated(c Conditioner) {
|
|
SetReadyCreatedWithMessage(c, "Created")
|
|
}
|
|
|
|
func SetReadyFailedWithMessage(c Conditioner, message string) {
|
|
c.SetCondition(metav1.Condition{
|
|
Type: zitadelv1alpha1.ConditionTypeReady,
|
|
Status: metav1.ConditionFalse,
|
|
Reason: zitadelv1alpha1.ConditionReasonFailed,
|
|
Message: message,
|
|
})
|
|
}
|
|
|
|
func SetReadyFailed(c Conditioner) {
|
|
SetReadyFailedWithMessage(c, "Failed")
|
|
}
|
|
|
|
func SetReadyWithDeployment(c Conditioner, sts *appsv1.Deployment) {
|
|
if sts.Status.Replicas == 0 || sts.Status.ReadyReplicas != sts.Status.Replicas {
|
|
c.SetCondition(metav1.Condition{
|
|
Type: zitadelv1alpha1.ConditionTypeReady,
|
|
Status: metav1.ConditionFalse,
|
|
Reason: zitadelv1alpha1.ConditionReasonDeploymentNotReady,
|
|
Message: "Not ready",
|
|
})
|
|
return
|
|
}
|
|
c.SetCondition(metav1.Condition{
|
|
Type: zitadelv1alpha1.ConditionTypeReady,
|
|
Status: metav1.ConditionTrue,
|
|
Reason: zitadelv1alpha1.ConditionReasonDeploymentReady,
|
|
Message: "Running",
|
|
})
|
|
}
|