From d96877033be9790d11b0212ab8825f93202d22a2 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 26 Jun 2023 15:02:54 -0700 Subject: [PATCH] refactor: :wrench: allow redis user to be configured Follow up #10366, 3df3c97deb284ecbf3363b90a45c6501957d1e98 --- .config/example.yml | 1 + chart/templates/_helpers.tpl | 1 + packages/backend/src/config/types.ts | 1 + packages/backend/src/db/redis.ts | 4 ++-- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.config/example.yml b/.config/example.yml index 16fa67142..ee61ebe25 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -60,6 +60,7 @@ redis: #pass: example-pass #prefix: example-prefix #db: 1 + #user: default # Please configure either MeiliSearch *or* Sonic. # If both MeiliSearch and Sonic configurations are present, MeiliSearch will take precedence. diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index b732fa5a4..62ff2f8ff 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -153,6 +153,7 @@ redis: pass: {{ .Values.redis.auth.password | quote }} #prefix: example-prefix #db: 1 + #user: default # ┌─────────────────────┐ #───┘ Sonic configuration └───────────────────────────────────── diff --git a/packages/backend/src/config/types.ts b/packages/backend/src/config/types.ts index 54332c993..e9d1dbb64 100644 --- a/packages/backend/src/config/types.ts +++ b/packages/backend/src/config/types.ts @@ -23,6 +23,7 @@ export type Source = { pass: string; db?: number; prefix?: string; + user?: string; }; elasticsearch: { host: string; diff --git a/packages/backend/src/db/redis.ts b/packages/backend/src/db/redis.ts index 0a88a0deb..a54bad2e7 100644 --- a/packages/backend/src/db/redis.ts +++ b/packages/backend/src/db/redis.ts @@ -5,9 +5,9 @@ export function createConnection() { return new Redis({ port: config.redis.port, host: config.redis.host, - family: config.redis.family == null ? 0 : config.redis.family, + family: config.redis.family ?? 0, password: config.redis.pass, - username: "default", + username: config.redis.user ?? "default", keyPrefix: `${config.redis.prefix}:`, db: config.redis.db || 0, tls: {