Skip to content

Commit

Permalink
Fix nil ptr for the redis-sentinel. (#642)
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Gupta <iamshubhamgupta2001@gmail.com>
  • Loading branch information
shubham-cmyk authored Sep 24, 2023
1 parent 87fa654 commit 26f9c0b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/v1beta1/redissentinel_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// ConvertTo converts this RedisSentinel to the Hub version (vbeta2).
// ConvertTo converts this RedisSentinel to the Hub version (v1beta2).
func (src *RedisSentinel) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*redisv1beta2.RedisSentinel)

Expand Down
5 changes: 0 additions & 5 deletions example/v1beta2/redis-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ spec:
limits:
cpu: 101m
memory: 128Mi
env:
- name: CUSTOM_ENV_VAR_1
value: "custom_value_1"
- name: CUSTOM_ENV_VAR_2
value: "custom_value_2"
# redisSecret:
# name: redis-secret
# key: password
Expand Down
6 changes: 5 additions & 1 deletion k8sutils/redis-sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func CreateRedisSentinel(cr *redisv1beta2.RedisSentinel) error {
TerminationGracePeriodSeconds: cr.Spec.TerminationGracePeriodSeconds,
}

if cr.Spec.RedisSentinelConfig.AdditionalSentinelConfig != nil {
if cr.Spec.RedisSentinelConfig != nil && cr.Spec.RedisSentinelConfig.AdditionalSentinelConfig != nil {
prop.ExternalConfig = cr.Spec.RedisSentinelConfig.AdditionalSentinelConfig
}

Expand Down Expand Up @@ -242,6 +242,10 @@ func (service RedisSentinelService) CreateRedisSentinelService(cr *redisv1beta2.

func getSentinelEnvVariable(cr *redisv1beta2.RedisSentinel) *[]corev1.EnvVar {

if cr.Spec.RedisSentinelConfig == nil {
return &[]corev1.EnvVar{}
}

envVar := &[]corev1.EnvVar{
{
Name: "MASTER_GROUP_NAME",
Expand Down

0 comments on commit 26f9c0b

Please sign in to comment.