Skip to content

Commit

Permalink
fix(config):handle empty redis password (#625)
Browse files Browse the repository at this point in the history
- handle empty redis password for js
- handle empty redis password for registry
- handle empty redis password for chartmuseum

Signed-off-by: Steven Zou <szou@vmware.com>

also fix #608
  • Loading branch information
steven-zou authored Apr 29, 2021
1 parent 8481e68 commit 0592321
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config/config/assets/jobservice-config.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ worker_pool:
backend: "redis"

redis_pool:
{{- if .Spec.WorkerPool.Redis.PasswordRef }}
redis_url: {{ "redis-password" | secretData .Spec.WorkerPool.Redis.PasswordRef | .Spec.WorkerPool.Redis.GetDSN }}
{{- else }}
redis_url: {{ "" | .Spec.WorkerPool.Redis.GetDSN }}
{{- end }}
namespace: {{ default ( printf "jobservice::%s::%s" .ObjectMeta.Namespace .ObjectMeta.Name ) .Spec.WorkerPool.Redis.Namespace }}
idle_timeout_second: {{ .Spec.WorkerPool.Redis.IdleTimeout.Duration.Seconds | int64 }}

Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/chartmuseum/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, chartMuseum *goharborv1.
})
}

if chartMuseum.Spec.Cache.Redis != nil {
if chartMuseum.Spec.Cache.Redis != nil && len(chartMuseum.Spec.Cache.Redis.PasswordRef) > 0 {
envs = append(envs, corev1.EnvVar{
Name: "CACHE_REDIS_PASSWORD",
ValueFrom: &corev1.EnvVarSource{
Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/registry/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, registry *goharborv1.Reg
})
}

if registry.Spec.Redis != nil {
if registry.Spec.Redis != nil && len(registry.Spec.Redis.PasswordRef) > 0 {
envs = append(envs, corev1.EnvVar{
Name: "REGISTRY_REDIS_PASSWORD",
ValueFrom: &corev1.EnvVarSource{
Expand Down
4 changes: 4 additions & 0 deletions manifests/cluster/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20983,7 +20983,11 @@ data:
backend: "redis"

redis_pool:
{{- if .Spec.WorkerPool.Redis.PasswordRef }}
redis_url: {{ "redis-password" | secretData .Spec.WorkerPool.Redis.PasswordRef | .Spec.WorkerPool.Redis.GetDSN }}
{{- else }}
redis_url: {{ "" | .Spec.WorkerPool.Redis.GetDSN }}
{{- end }}
namespace: {{ default ( printf "jobservice::%s::%s" .ObjectMeta.Namespace .ObjectMeta.Name ) .Spec.WorkerPool.Redis.Namespace }}
idle_timeout_second: {{ .Spec.WorkerPool.Redis.IdleTimeout.Duration.Seconds | int64 }}

Expand Down
4 changes: 4 additions & 0 deletions manifests/harbor/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13527,7 +13527,11 @@ data:
backend: "redis"

redis_pool:
{{- if .Spec.WorkerPool.Redis.PasswordRef }}
redis_url: {{ "redis-password" | secretData .Spec.WorkerPool.Redis.PasswordRef | .Spec.WorkerPool.Redis.GetDSN }}
{{- else }}
redis_url: {{ "" | .Spec.WorkerPool.Redis.GetDSN }}
{{- end }}
namespace: {{ default ( printf "jobservice::%s::%s" .ObjectMeta.Namespace .ObjectMeta.Name ) .Spec.WorkerPool.Redis.Namespace }}
idle_timeout_second: {{ .Spec.WorkerPool.Redis.IdleTimeout.Duration.Seconds | int64 }}

Expand Down

0 comments on commit 0592321

Please sign in to comment.