-
Notifications
You must be signed in to change notification settings - Fork 0
/
reporter.go
34 lines (26 loc) · 1.1 KB
/
reporter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package rabbitmq
import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
openstackv1beta1 "github.com/ianunruh/openstack-operator/api/v1beta1"
"github.com/ianunruh/openstack-operator/pkg/template"
)
func NewReporter(instance *openstackv1beta1.RabbitMQ, k8sClient client.Client, recorder record.EventRecorder) *Reporter {
return &Reporter{
reporter: template.NewReporter(instance, &instance.Status.Conditions, k8sClient, recorder),
}
}
type Reporter struct {
reporter *template.Reporter
}
func (r *Reporter) Pending(ctx context.Context, message string, args ...any) error {
return r.reporter.UpdateReadyCondition(ctx, metav1.ConditionFalse, openstackv1beta1.ReasonPending, message, args...)
}
func (r *Reporter) Running(ctx context.Context) error {
return r.reporter.UpdateReadyCondition(ctx, metav1.ConditionTrue, openstackv1beta1.ReasonRunning, "RabbitMQ is running")
}
func AddReadyCheck(cw *template.ConditionWaiter, instance *openstackv1beta1.RabbitMQ) {
cw.AddReadyCheck(instance, instance.Status.Conditions)
}