Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
drivebyer committed Nov 15, 2024
1 parent a6d6d89 commit 95256a7
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package redisreplication

import (
"context"
"sigs.k8s.io/controller-runtime/pkg/log"
"time"

redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
Expand All @@ -15,6 +14,7 @@ import (
"k8s.io/client-go/kubernetes"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
)

// Reconciler reconciles a RedisReplication object
Expand Down
3 changes: 0 additions & 3 deletions pkg/k8sutils/finalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,6 @@ func TestFinalizeRedisPVC(t *testing.T) {

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {

cr := &v1beta2.Redis{
ObjectMeta: metav1.ObjectMeta{
Name: "test-redis",
Expand Down Expand Up @@ -689,7 +688,6 @@ func TestFinalizeRedisReplicationPVC(t *testing.T) {

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {

var k8sClient *k8sClientFake.Clientset
if tc.existingPVCs != nil {
k8sClient = k8sClientFake.NewSimpleClientset(helperToRuntimeObjects(tc.existingPVCs)...)
Expand Down Expand Up @@ -760,7 +758,6 @@ func TestFinalizeRedisClusterPVC(t *testing.T) {

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {

var k8sClient *k8sClientFake.Clientset
if tc.existingPVCs != nil {
k8sClient = k8sClientFake.NewSimpleClientset(helperToRuntimeObjects(tc.existingPVCs)...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8sutils/poddisruption.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package k8sutils
import (
"context"
"fmt"
"sigs.k8s.io/controller-runtime/pkg/log"

commonapi "github.com/OT-CONTAINER-KIT/redis-operator/api"
redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
Expand All @@ -13,6 +12,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/log"
)

// CreateRedisLeaderPodDisruptionBudget check and create a PodDisruptionBudget for Leaders
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8sutils/redis-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package k8sutils

import (
"context"
"sigs.k8s.io/controller-runtime/pkg/log"
"strconv"
"strings"

Expand All @@ -12,6 +11,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/log"
)

// RedisClusterSTS is a interface to call Redis Statefulset function
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8sutils/redis-replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package k8sutils

import (
"context"
"sigs.k8s.io/controller-runtime/pkg/log"

redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
"github.com/OT-CONTAINER-KIT/redis-operator/pkg/util"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/log"
)

// CreateReplicationService method will create replication service for Redis
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8sutils/redis-sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"errors"
"sigs.k8s.io/controller-runtime/pkg/log"

redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
"github.com/OT-CONTAINER-KIT/redis-operator/pkg/util"
Expand All @@ -14,6 +13,7 @@ import (
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/log"
)

// RedisSentinelSTS is a interface to call Redis Statefulset function
Expand Down
1 change: 1 addition & 0 deletions pkg/k8sutils/redis-standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package k8sutils

import (
"context"

redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
"github.com/OT-CONTAINER-KIT/redis-operator/pkg/util"
"k8s.io/client-go/kubernetes"
Expand Down
3 changes: 1 addition & 2 deletions pkg/k8sutils/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import (
"strconv"
"strings"

"sigs.k8s.io/controller-runtime/pkg/log"

redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
redis "github.com/redis/go-redis/v9"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/remotecommand"
"sigs.k8s.io/controller-runtime/pkg/log"
)

// RedisDetails will hold the information for Redis Pod
Expand Down
3 changes: 0 additions & 3 deletions pkg/k8sutils/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ func TestGetRedisHostname(t *testing.T) {
}

func TestCreateSingleLeaderRedisCommand(t *testing.T) {

cr := &redisv1beta2.RedisCluster{}
cmd := CreateSingleLeaderRedisCommand(context.TODO(), cr)

Expand Down Expand Up @@ -388,7 +387,6 @@ func TestGetRedisTLSArgs(t *testing.T) {
}

func TestCreateRedisReplicationCommand(t *testing.T) {

type secret struct {
name string
namespace string
Expand Down Expand Up @@ -626,7 +624,6 @@ func TestGetContainerID(t *testing.T) {
}

func Test_checkAttachedSlave(t *testing.T) {

tests := []struct {
name string
podName string
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8sutils/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package k8sutils

import (
"context"
"sigs.k8s.io/controller-runtime/pkg/log"

"github.com/banzaicloud/k8s-objectmatcher/patch"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/log"
)

const (
Expand Down
3 changes: 0 additions & 3 deletions pkg/k8sutils/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ func Test_createService(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

var k8sClient *k8sClientFake.Clientset
if tt.exist {
k8sClient = k8sClientFake.NewSimpleClientset(tt.service.DeepCopyObject())
Expand Down Expand Up @@ -406,7 +405,6 @@ func Test_updateService(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

k8sClient := k8sClientFake.NewSimpleClientset(tt.current.DeepCopyObject())

err := updateService(context.TODO(), k8sClient, tt.servinceNamespace, tt.updated)
Expand Down Expand Up @@ -459,7 +457,6 @@ func Test_getService(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

var k8sClient *k8sClientFake.Clientset
if tt.have != nil {
k8sClient = k8sClientFake.NewSimpleClientset(tt.have.DeepCopyObject())
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8sutils/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"path"
"sigs.k8s.io/controller-runtime/pkg/log"
"sort"
"strconv"
"strings"
Expand All @@ -22,6 +21,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/utils/env"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/log"
)

type StatefulSet interface {
Expand Down
4 changes: 0 additions & 4 deletions pkg/k8sutils/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func TestGetVolumeMount(t *testing.T) {
}

func Test_GetStatefulSet(t *testing.T) {

tests := []struct {
name string
sts appsv1.StatefulSet
Expand Down Expand Up @@ -238,7 +237,6 @@ func Test_GetStatefulSet(t *testing.T) {
}

func Test_createStatefulSet(t *testing.T) {

tests := []struct {
name string
sts appsv1.StatefulSet
Expand Down Expand Up @@ -287,7 +285,6 @@ func Test_createStatefulSet(t *testing.T) {
}

func TestUpdateStatefulSet(t *testing.T) {

tests := []struct {
name string
existingStsSpec appsv1.StatefulSetSpec
Expand Down Expand Up @@ -409,7 +406,6 @@ func TestUpdateStatefulSet(t *testing.T) {
}

func TestCreateOrUpdateStateFul(t *testing.T) {

tests := []struct {
name string
stsParams statefulSetParameters
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8sutils/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package k8sutils
import (
"context"
"reflect"
"sigs.k8s.io/controller-runtime/pkg/log"

"github.com/OT-CONTAINER-KIT/redis-operator/api/status"
redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
Expand All @@ -12,6 +11,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"sigs.k8s.io/controller-runtime/pkg/log"
)

// UpdateRedisClusterStatus will update the status of the RedisCluster
Expand Down

0 comments on commit 95256a7

Please sign in to comment.