• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

chideat / valkey-operator / 14173979426

31 Mar 2025 02:26PM UTC coverage: 10.247% (-3.3%) from 13.534%
14173979426

push

github

web-flow
feat: added webhooks

168 of 2201 new or added lines in 67 files covered. (7.63%)

1254 existing lines in 61 files now uncovered.

2074 of 20241 relevant lines covered (10.25%)

0.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

28.57
/internal/controller/sentinel_controller.go
1
/*
2
Copyright 2024 chideat.
3

4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7

8
    http://www.apache.org/licenses/LICENSE-2.0
9

10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16

17
package controller
18

19
import (
20
        "context"
21

22
        appsv1 "k8s.io/api/apps/v1"
23
        corev1 "k8s.io/api/core/v1"
24
        "k8s.io/apimachinery/pkg/api/errors"
25
        "k8s.io/apimachinery/pkg/runtime"
26
        "k8s.io/client-go/tools/record"
27
        ctrl "sigs.k8s.io/controller-runtime"
28
        "sigs.k8s.io/controller-runtime/pkg/client"
29
        "sigs.k8s.io/controller-runtime/pkg/controller"
30
        "sigs.k8s.io/controller-runtime/pkg/log"
31
        "sigs.k8s.io/controller-runtime/pkg/reconcile"
32

33
        "github.com/chideat/valkey-operator/api/v1alpha1"
34
        "github.com/chideat/valkey-operator/internal/ops"
35
)
36

37
// SentinelReconciler reconciles a Sentinel object
38
type SentinelReconciler struct {
39
        client.Client
40
        Scheme        *runtime.Scheme
41
        EventRecorder record.EventRecorder
42
        Engine        *ops.OpEngine
43
}
44

45
// +kubebuilder:rbac:groups=valkey.buf.red,resources=sentinels,verbs=get;list;watch;create;update;patch;delete
46
// +kubebuilder:rbac:groups=valkey.buf.red,resources=sentinels/status,verbs=get;update;patch
47
// +kubebuilder:rbac:groups=valkey.buf.red,resources=sentinels/finalizers,verbs=update
48

49
// Reconcile is part of the main kubernetes reconciliation loop which aims to
50
// move the current state of the cluster closer to the desired state.
51
func (r *SentinelReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
1✔
52
        logger := log.FromContext(ctx).WithValues("target", req.String())
1✔
53

1✔
54
        var inst v1alpha1.Sentinel
1✔
55
        if err := r.Get(ctx, req.NamespacedName, &inst); err != nil {
1✔
56
                if errors.IsNotFound(err) {
×
57
                        return reconcile.Result{}, nil
×
58
                }
×
NEW
59
                logger.Error(err, "failed to get Sentinel")
×
60
                return reconcile.Result{}, err
×
61
        }
62
        return r.Engine.Run(ctx, &inst)
1✔
63
}
64

65
// SetupWithManager sets up the controller with the Manager.
66
func (r *SentinelReconciler) SetupWithManager(mgr ctrl.Manager) error {
×
67
        return ctrl.NewControllerManagedBy(mgr).
×
68
                For(&v1alpha1.Sentinel{}).
×
69
                WithOptions(controller.Options{MaxConcurrentReconciles: 8}).
×
70
                Owns(&appsv1.StatefulSet{}).
×
71
                Owns(&corev1.Service{}).
×
72
                Owns(&corev1.ConfigMap{}).
×
73
                Owns(&corev1.Secret{}).
×
74
                Complete(r)
×
75
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc