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

chideat / valkey-operator / 13214360144

08 Feb 2025 09:25AM UTC coverage: 13.534%. First build
13214360144

push

github

web-flow
feat: added features for user, added suit tests (#2)

* chore: updated github actions

* feat: added user recocile, added suit tests

* fix: upgrade x/net for high cve

* fix: update test command

* chore: updated github actions

* chore: updated docker file

108 of 501 new or added lines in 31 files covered. (21.56%)

3048 of 22521 relevant lines covered (13.53%)

0.15 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✔
NEW
56
                if errors.IsNotFound(err) {
×
NEW
57
                        return reconcile.Result{}, nil
×
NEW
58
                }
×
NEW
59
                logger.Error(err, "failed to get RedisSentinel")
×
NEW
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).
×
NEW
68
                For(&v1alpha1.Sentinel{}).
×
NEW
69
                WithOptions(controller.Options{MaxConcurrentReconciles: 8}).
×
NEW
70
                Owns(&appsv1.StatefulSet{}).
×
NEW
71
                Owns(&corev1.Service{}).
×
NEW
72
                Owns(&corev1.ConfigMap{}).
×
NEW
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