goharbor / harbor-operator

Kubernetes operator for Harbor service components
Apache License 2.0
343 stars 106 forks source link

Allow redis password contains special characters #1055

Closed MinerYang closed 1 year ago

MinerYang commented 1 year ago

fix: https://github.com/goharbor/harbor-operator/issues/1054

## core && registry 
ubuntu@miner:~$ kubectl get secret harborcluster-sample-harbor-harbor-core -n test -o yaml | grep REDIS
  _REDIS_URL_CORE: cmVkaXM6Ly86T2RMNTFGVnpUaCU0MFIlMjUlNUUlNDBAMTAuMTg2LjU1LjM1OjYzNzkvMD9pZGxlX3RpbWVvdXRfc2Vjb25kcz0zMA==
  _REDIS_URL_REG: cmVkaXM6Ly86T2RMNTFGVnpUaCU0MFIlMjUlNUUlNDBAMTAuMTg2LjU1LjM1OjYzNzkvMT9pZGxlX3RpbWVvdXRfc2Vjb25kcz0zMA==

## exporter for jobservice
kubectl get deployment.apps/harborcluster-sample-harbor-harbor-exporter -n test -o yaml
...
- name: HARBOR_REDIS_URL
          value: redis://:OdL51FVzTh%40R%25%5E%40@10.186.55.35:6379/2

## trivy, no need to escape special character due to using different function GetDSN()
ubuntu@miner:~$ kubectl get secret harborcluster-sample-harbor-harbor-trivy -n test -o yaml | grep REDIS
  SCANNER_JOB_QUEUE_REDIS_URL: cmVkaXM6Ly86T2RMNTFGVnpUaCU0MFIlMjUlNUUlNDBAMTAuMTg2LjU1LjM1OjYzNzkvNQ==
  SCANNER_REDIS_URL: cmVkaXM6Ly86T2RMNTFGVnpUaCU0MFIlMjUlNUUlNDBAMTAuMTg2LjU1LjM1OjYzNzkvNQ==
  SCANNER_STORE_REDIS_URL: cmVkaXM6Ly86T2RMNTFGVnpUaCU0MFIlMjUlNUUlNDBAMTAuMTg2LjU1LjM1OjYzNzkvNQ==

## distribution using harbor-redis password directly, no need to change
- name: REGISTRY_REDIS_PASSWORD
          valueFrom:
            secretKeyRef:
              key: redis-password
              name: harbor-redis
              optional: true

## chartmuseum using harbor-redis password directly, no need to change
- name: CACHE_REDIS_PASSWORD
          valueFrom:
            secretKeyRef:
              key: redis-password
              name: harbor-redis
              optional: false
const (
    coreRedisDatabaseIndex        = 0
    registryRedisDatabaseIndex    = 1
    jobServiceRedisDatabaseIndex  = 2
    chartMuseumRedisDatabaseIndex = 3
    trivyRedisDatabaseIndex       = 5
)
chlins commented 1 year ago

@MinerYang The UT test failed, please fix it and then merge this PR.

MinerYang commented 1 year ago

a notary server test failed with reconcile error Message: "error trying to reach service: dial tcp 10.244.2.33:4443: connect: connection refused",