Skip to content

Commit

Permalink
Allow redis password contains special characters (#1055)
Browse files Browse the repository at this point in the history
allow redis password contains special characters

Signed-off-by: yminer <[email protected]>

fix lint

update trivy secret
  • Loading branch information
MinerYang committed Jul 17, 2023
1 parent b600049 commit e8eedc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions controllers/goharbor/core/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package core
import (
"context"
"fmt"
"net/url"

goharborv1 "github.com/goharbor/harbor-operator/apis/goharbor.io/v1beta1"
harbormetav1 "github.com/goharbor/harbor-operator/apis/meta/v1alpha1"
Expand Down Expand Up @@ -41,8 +42,8 @@ func (r *Reconciler) GetSecret(ctx context.Context, core *goharborv1.Core) (*cor

redisPassword = string(password)
}

coreCacheDSN := core.Spec.Redis.GetDSNStringWithRawPassword(redisPassword)
// support redis password contains special character by using url.QueryEscape
coreCacheDSN := core.Spec.Redis.GetDSNStringWithRawPassword(url.QueryEscape(redisPassword))

var registryPassword string

Expand All @@ -64,8 +65,8 @@ func (r *Reconciler) GetSecret(ctx context.Context, core *goharborv1.Core) (*cor

registryPassword = string(password)
}

registryCacheDSN := core.Spec.Components.Registry.Redis.GetDSNStringWithRawPassword(registryPassword)
// support redis password contains special character by using url.QueryEscape
registryCacheDSN := core.Spec.Components.Registry.Redis.GetDSNStringWithRawPassword(url.QueryEscape(registryPassword))

return &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Expand Down
4 changes: 2 additions & 2 deletions controllers/goharbor/exporter/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ func (r *Reconciler) getJobServiceRedisURL(ctx context.Context, exporter *goharb
if redisPassword == "" {
logger.Get(ctx).Info("redis password secret of jobservice not found", "secret", exporter.Spec.JobService.Redis.PasswordRef)
}

return exporter.Spec.JobService.Redis.GetDSNStringWithRawPassword(redisPassword), nil
// support redis password contains special character by using url.QueryEscape
return exporter.Spec.JobService.Redis.GetDSNStringWithRawPassword(url.QueryEscape(redisPassword)), nil
}

func (r *Reconciler) getValueFromSecret(ctx context.Context, namespace, name, key string) (string, error) {
Expand Down

0 comments on commit e8eedc5

Please sign in to comment.