Skip to content

Commit

Permalink
syle: run gofumpt
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Gupta <[email protected]>
  • Loading branch information
shubham-cmyk committed Mar 3, 2024
1 parent 2c2698a commit 1977ff1
Show file tree
Hide file tree
Showing 23 changed files with 26 additions and 43 deletions.
3 changes: 1 addition & 2 deletions api/v1beta1/redis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ type RedisSpec struct {
}

// RedisStatus defines the observed state of Redis
type RedisStatus struct {
}
type RedisStatus struct{}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
Expand Down
3 changes: 1 addition & 2 deletions api/v1beta1/rediscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ type RedisFollower struct {
}

// RedisClusterStatus defines the observed state of RedisCluster
type RedisClusterStatus struct {
}
type RedisClusterStatus struct{}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
Expand Down
3 changes: 1 addition & 2 deletions api/v1beta1/redisreplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ func (cr *RedisReplicationSpec) GetReplicationCounts(t string) int32 {
}

// RedisStatus defines the observed state of Redis
type RedisReplicationStatus struct {
}
type RedisReplicationStatus struct{}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
Expand Down
3 changes: 1 addition & 2 deletions api/v1beta1/redissentinel_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ type RedisSentinelConfig struct {
common.RedisSentinelConfig `json:",inline"`
}

type RedisSentinelStatus struct {
}
type RedisSentinelStatus struct{}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
Expand Down
3 changes: 1 addition & 2 deletions api/v1beta2/redis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ type RedisSpec struct {
}

// RedisStatus defines the observed state of Redis
type RedisStatus struct {
}
type RedisStatus struct{}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
Expand Down
3 changes: 1 addition & 2 deletions api/v1beta2/redisreplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ func (cr *RedisReplicationSpec) GetReplicationCounts(t string) int32 {
}

// RedisStatus defines the observed state of Redis
type RedisReplicationStatus struct {
}
type RedisReplicationStatus struct{}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
Expand Down
3 changes: 1 addition & 2 deletions api/v1beta2/redissentinel_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ type RedisSentinelConfig struct {
common.RedisSentinelConfig `json:",inline"`
}

type RedisSentinelStatus struct {
}
type RedisSentinelStatus struct{}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
Expand Down
2 changes: 0 additions & 2 deletions controllers/redisreplication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type RedisReplicationReconciler struct {
}

func (r *RedisReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {

reqLogger := r.Log.WithValues("Request.Namespace", req.Namespace, "Request.Name", req.Name)
reqLogger.Info("Reconciling opstree redis replication controller")
instance := &redisv1beta2.RedisReplication{}
Expand Down Expand Up @@ -91,7 +90,6 @@ func (r *RedisReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Req

reqLogger.Info("Will reconcile redis operator in again 10 seconds")
return ctrl.Result{RequeueAfter: time.Second * 10}, nil

}

// SetupWithManager sets up the controller with the Manager.
Expand Down
2 changes: 0 additions & 2 deletions controllers/redisreplication_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ var _ = Describe("Redis replication test", func() {

Context("When creating a redis replication CR", func() {
It("should create a statefulset, service", func() {

svc := &corev1.Service{}
sts := &appsv1.StatefulSet{}

Expand Down Expand Up @@ -101,7 +100,6 @@ var _ = Describe("Redis replication test", func() {
"redis_setup_type": "replication",
"role": "replication",
}))

})

Context("then deleting the redis replication CR", func() {
Expand Down
7 changes: 4 additions & 3 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ import (
// +kubebuilder:scaffold:imports
)

var k8sClient client.Client
var testEnv *envtest.Environment
var (
k8sClient client.Client
testEnv *envtest.Environment
)

const (
ns = "default"
Expand Down Expand Up @@ -136,5 +138,4 @@ var _ = BeforeSuite(func() {
err := testEnv.Stop()
Expect(err).ToNot(HaveOccurred())
}()

})
1 change: 1 addition & 0 deletions k8sutils/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
func mockK8sConfigProvider() (*rest.Config, error) {
return &rest.Config{}, nil
}

func mockInvalidK8sConfigProvider() (*rest.Config, error) {
return nil, errors.New("invalid configuration")
}
Expand Down
3 changes: 1 addition & 2 deletions k8sutils/cluster-scaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ func getAttachedFollowerNodeIDs(ctx context.Context, client kubernetes.Interface
slaveIDs = append(slaveIDs, parts[0])
}
}

}

logger.V(1).Info("Slaves Nodes attached to", "node", masterNodeID, "are", slaveIDs)
Expand Down Expand Up @@ -345,7 +344,7 @@ func RemoveRedisFollowerNodesFromCluster(ctx context.Context, client kubernetes.
// Remove redis cluster node would remove last node to the existing redis cluster using redis-cli
func RemoveRedisNodeFromCluster(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster, removePod RedisDetails) {
var cmd []string
//currentRedisCount := CheckRedisNodeCount(ctx, client, logger, cr, "leader")
// currentRedisCount := CheckRedisNodeCount(ctx, client, logger, cr, "leader")

Check warning on line 347 in k8sutils/cluster-scaling.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/cluster-scaling.go#L347

Added line #L347 was not covered by tests

existingPod := RedisDetails{
PodName: cr.ObjectMeta.Name + "-leader-0",
Expand Down
2 changes: 1 addition & 1 deletion k8sutils/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package k8sutils
import (
"context"
"fmt"

"k8s.io/utils/env"

redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
Expand Down Expand Up @@ -192,6 +193,5 @@ func finalizeRedisReplicationPVC(client kubernetes.Interface, logger logr.Logger
}

func finalizeRedisSentinelPVC(cr *redisv1beta2.RedisSentinel) error {

return nil
}
3 changes: 2 additions & 1 deletion k8sutils/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ func Test_generateObjectMetaInformation(t *testing.T) {
name: "test",
namespace: "default",
labels: map[string]string{"test": "test"},
annotations: map[string]string{"test": "test"}},
annotations: map[string]string{"test": "test"},
},
want: metav1.ObjectMeta{
Name: "test",
Namespace: "default",
Expand Down
3 changes: 2 additions & 1 deletion k8sutils/redis-replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ func Test_generateRedisReplicationParams(t *testing.T) {
ClusterMode: false,
NodeConfVolume: false,
NodeSelector: map[string]string{
"node-role.kubernetes.io/infra": "worker"},
"node-role.kubernetes.io/infra": "worker",
},
PodSecurityContext: &corev1.PodSecurityContext{
RunAsUser: pointer.Int64(1000),
FSGroup: pointer.Int64(1000),
Expand Down
8 changes: 0 additions & 8 deletions k8sutils/redis-sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ func CreateRedisSentinel(ctx context.Context, client kubernetes.Interface, logge
}

return prop.CreateRedisSentinelSetup(ctx, client, logger, cr, cl, dcl)

}

// Create RedisSentinel Service
func CreateRedisSentinelService(cr *redisv1beta2.RedisSentinel, cl kubernetes.Interface) error {

prop := RedisSentinelService{
RedisServiceRole: "sentinel",
}
Expand All @@ -80,7 +78,6 @@ func (service RedisSentinelSTS) CreateRedisSentinelSetup(ctx context.Context, cl
cr.Spec.Sidecars,
cl,
)

if err != nil {
logger.Error(err, "Cannot create Sentinel statefulset for Redis")
return err
Expand All @@ -90,7 +87,6 @@ func (service RedisSentinelSTS) CreateRedisSentinelSetup(ctx context.Context, cl

// Create Redis Sentile Params for the statefulset
func generateRedisSentinelParams(cr *redisv1beta2.RedisSentinel, replicas int32, externalConfig *string, affinity *corev1.Affinity) statefulSetParameters {

res := statefulSetParameters{
Replicas: &replicas,
ClusterMode: false,
Expand Down Expand Up @@ -123,7 +119,6 @@ func generateRedisSentinelParams(cr *redisv1beta2.RedisSentinel, replicas int32,

// generateRedisSentinelInitContainerParams generates Redis sentinel initcontainer information
func generateRedisSentinelInitContainerParams(cr *redisv1beta2.RedisSentinel) initContainerParameters {

initcontainerProp := initContainerParameters{}

if cr.Spec.InitContainer != nil {
Expand Down Expand Up @@ -190,7 +185,6 @@ func generateRedisSentinelContainerParams(ctx context.Context, client kubernetes
}

return containerProp

}

// Get the Count of the Sentinel
Expand Down Expand Up @@ -243,7 +237,6 @@ func (service RedisSentinelService) CreateRedisSentinelService(cr *redisv1beta2.
return err
}
return nil

}

func getSentinelEnvVariable(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisSentinel, dcl dynamic.Interface) *[]corev1.EnvVar {
Expand Down Expand Up @@ -289,7 +282,6 @@ func getSentinelEnvVariable(ctx context.Context, client kubernetes.Interface, lo
})
}
return envVar

}

func getRedisReplicationMasterIP(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisSentinel, dcl dynamic.Interface) string {
Expand Down
3 changes: 2 additions & 1 deletion k8sutils/redis-sentinel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func Test_generateRedisSentinelParams(t *testing.T) {
ClusterMode: false,
NodeConfVolume: false,
NodeSelector: map[string]string{
"node-role.kubernetes.io/infra": "worker"},
"node-role.kubernetes.io/infra": "worker",
},
PodSecurityContext: &corev1.PodSecurityContext{
RunAsUser: pointer.Int64(1000),
FSGroup: pointer.Int64(1000),
Expand Down
1 change: 0 additions & 1 deletion k8sutils/redis-standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func generateRedisStandaloneParams(cr *redisv1beta2.Redis) statefulSetParameters
}
if cr.Spec.RedisExporter != nil {
res.EnableMetrics = cr.Spec.RedisExporter.Enabled

}
if cr.Spec.ServiceAccountName != nil {
res.ServiceAccountName = cr.Spec.ServiceAccountName
Expand Down
3 changes: 2 additions & 1 deletion k8sutils/redis-standalone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func Test_generateRedisStandaloneParams(t *testing.T) {
// "opstreelabs.in.redis": "true"},
// },
NodeSelector: map[string]string{
"node-role.kubernetes.io/infra": "worker"},
"node-role.kubernetes.io/infra": "worker",
},
PodSecurityContext: &corev1.PodSecurityContext{
RunAsUser: pointer.Int64(1000),
FSGroup: pointer.Int64(1000),
Expand Down
1 change: 0 additions & 1 deletion k8sutils/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ func checkAttachedSlave(ctx context.Context, client kubernetes.Interface, logger
}

return ""

}

func CreateMasterSlaveReplication(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisReplication, masterPods []string, slavePods []string) error {
Expand Down
2 changes: 1 addition & 1 deletion k8sutils/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestCheckRedisNodePresence(t *testing.T) {
csvOutput.FieldsPerRecord = -1
nodes, _ := csvOutput.ReadAll()

var tests = []struct {
tests := []struct {
nodes [][]string
ip string
want bool
Expand Down
4 changes: 1 addition & 3 deletions k8sutils/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ const (
redisExporterPortName = "redis-exporter"
)

var (
serviceType corev1.ServiceType
)
var serviceType corev1.ServiceType

// exporterPortProvider return the exporter port if bool is true
type exporterPortProvider func() (port int, enable bool)
Expand Down
3 changes: 2 additions & 1 deletion k8sutils/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ func getProbeInfo(probe *commonapi.Probe) *corev1.Probe {
// getEnvironmentVariables returns all the required Environment Variables
func getEnvironmentVariables(role string, enabledPassword *bool, secretName *string,
secretKey *string, persistenceEnabled *bool, tlsConfig *redisv1beta2.TLSConfig,
aclConfig *redisv1beta2.ACLConfig, envVar *[]corev1.EnvVar, port *int, clusterVersion *string) []corev1.EnvVar {
aclConfig *redisv1beta2.ACLConfig, envVar *[]corev1.EnvVar, port *int, clusterVersion *string,
) []corev1.EnvVar {
envVars := []corev1.EnvVar{
{Name: "SERVER_MODE", Value: role},
{Name: "SETUP_MODE", Value: role},
Expand Down

0 comments on commit 1977ff1

Please sign in to comment.