Skip to content

Commit

Permalink
Update redis-cluster.go
Browse files Browse the repository at this point in the history
  • Loading branch information
drivebyer authored May 7, 2024
1 parent 8d17d28 commit fb71c1a
Showing 1 changed file with 33 additions and 43 deletions.
76 changes: 33 additions & 43 deletions k8sutils/redis-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,49 +35,39 @@ type RedisClusterService struct {
// generateRedisClusterParams generates Redis cluster information

func generateRedisClusterParams(cr *redisv1beta2.RedisCluster, replicas int32, externalConfig *string, params RedisClusterSTS) statefulSetParameters {
if cr == nil {
panic("RedisCluster is empty")
}
if cr.Spec == nil {
panic("RedisCluster.Spec cannot be empty")
}
if cr.Spec.Storage == nil {
cr.Spec.Storage = &redisv1beta2.Storage{}
}

res := statefulSetParameters{
Replicas: &replicas,
ClusterMode: true,
ClusterVersion: cr.Spec.ClusterVersion,
NodeConfVolume: cr.Spec.Storage.NodeConfVolume,
NodeSelector: params.NodeSelector,
PodSecurityContext: cr.Spec.PodSecurityContext,
PriorityClassName: cr.Spec.PriorityClassName,
Affinity: params.Affinity,
TerminationGracePeriodSeconds: params.TerminationGracePeriodSeconds,
Tolerations: params.Tolerations,
ServiceAccountName: cr.Spec.ServiceAccountName,
UpdateStrategy: cr.Spec.KubernetesConfig.UpdateStrategy,
IgnoreAnnotations: cr.Spec.KubernetesConfig.IgnoreAnnotations,
HostNetwork: cr.Spec.HostNetwork,
}
if cr.Spec.RedisExporter != nil {
res.EnableMetrics = cr.Spec.RedisExporter.Enabled
}
if cr.Spec.KubernetesConfig.ImagePullSecrets != nil {
res.ImagePullSecrets = cr.Spec.KubernetesConfig.ImagePullSecrets
}
if cr.Spec.Storage != nil {
res.PersistentVolumeClaim = cr.Spec.Storage.VolumeClaimTemplate
res.NodeConfPersistentVolumeClaim = cr.Spec.Storage.NodeConfVolumeClaimTemplate
}
if externalConfig != nil {
res.ExternalConfig = externalConfig
}
if _, found := cr.ObjectMeta.GetAnnotations()[AnnotationKeyRecreateStatefulset]; found {
res.RecreateStatefulSet = true
}
return res
res := statefulSetParameters{
Replicas: &replicas,
ClusterMode: true,
ClusterVersion: cr.Spec.ClusterVersion,
NodeSelector: params.NodeSelector,
PodSecurityContext: cr.Spec.PodSecurityContext,
PriorityClassName: cr.Spec.PriorityClassName,
Affinity: params.Affinity,
TerminationGracePeriodSeconds: params.TerminationGracePeriodSeconds,
Tolerations: params.Tolerations,
ServiceAccountName: cr.Spec.ServiceAccountName,
UpdateStrategy: cr.Spec.KubernetesConfig.UpdateStrategy,
IgnoreAnnotations: cr.Spec.KubernetesConfig.IgnoreAnnotations,
HostNetwork: cr.Spec.HostNetwork,
}
if cr.Spec.RedisExporter != nil {
res.EnableMetrics = cr.Spec.RedisExporter.Enabled
}
if cr.Spec.KubernetesConfig.ImagePullSecrets != nil {
res.ImagePullSecrets = cr.Spec.KubernetesConfig.ImagePullSecrets
}
if cr.Spec.Storage != nil {
res.PersistentVolumeClaim = cr.Spec.Storage.VolumeClaimTemplate
res.NodeConfVolume = cr.Spec.Storage.NodeConfVolume
res.NodeConfPersistentVolumeClaim = cr.Spec.Storage.NodeConfVolumeClaimTemplate
}
if externalConfig != nil {
res.ExternalConfig = externalConfig
}
if _, found := cr.ObjectMeta.GetAnnotations()[AnnotationKeyRecreateStatefulset]; found {
res.RecreateStatefulSet = true
}
return res
}

Check failure on line 72 in k8sutils/redis-cluster.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 73 in k8sutils/redis-cluster.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
Expand Down

0 comments on commit fb71c1a

Please sign in to comment.